Skip to content

Instantly share code, notes, and snippets.

@deniqwe
Created September 10, 2017 18:51
Show Gist options
  • Select an option

  • Save deniqwe/e1dc9cd3181f88e4c2a53153a7d8aa0f to your computer and use it in GitHub Desktop.

Select an option

Save deniqwe/e1dc9cd3181f88e4c2a53153a7d8aa0f to your computer and use it in GitHub Desktop.
<?php
$ru_months = array( 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь' );
$en_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
$date_arr = explode(" ", date("d F Y", strtotime($new->publish_date)));
$day = intval($date_arr[0]);
$month = $date_arr[1];
$year = $date_arr[2];
$month_index = array_search($month, $en_months);
if(mb_substr($ru_months[$month_index], -1) == 'т') {
$date = $day . ' ' . $ru_months[$month_index] . 'a' . " " . $year;
} else {
$date = $day . ' ' . mb_substr($ru_months[$month_index], 0, -1) . 'я' . " " . $year;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment