correct rus date event

This commit is contained in:
arlemp@selectel.ru
2021-11-05 12:53:09 +03:00
parent 9d7c1a13ff
commit 7262b4a43a
2 changed files with 43 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
<?php echo calend_block(date('m'), date('Y'), true);
setlocale(LC_ALL, 'ru_RU', 'ru_RU.UTF-8', 'ru', 'russian');
# три последних эвента
@@ -9,7 +11,7 @@ $posts = get_posts( array(
'order' => 'ASC',
'meta_query' => array(array('key' => 'startevent')),
'post_type' => 'post',
//'post_status' => 'publish, future',
//'post_status' => 'publish',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
) );
@@ -24,7 +26,7 @@ if( $posts ):?>
<div class="event">
<?$eventdate = get_post_meta( $post->ID, 'startevent', true );?>
<div class="news_date"><?=date_i18n('j F Y', strtotime($eventdate))?></div>
<div class="news_date"><?=eventdate_str($eventdate)?></div>
<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
</div>

View File

@@ -190,6 +190,44 @@ function isContainsRussianLetters($text = false) {
return false;
}
function eventdate_str($date){
$month = array(
"01" => "января",
"02" => "февраля",
"03" => "марта",
"04" => "апреля",
"05" => "мая",
"06" => "июня",
"07" => "июля",
"08" => "августа",
"09" => "сентября",
"10" => "октября",
"11" => "ноября",
"12" => "декабря"
);
$findT = strpos($date, 'T');
if ($findT){
$currdatetime = substr($date, 0, $findT);
}
else {
$currdatetime = $date;
}
$currdate = explode("-", $currdatetime);
return $currdate[2].' '.$month[$currdate[1]].' '.$currdate[0];
}
function express_slug($value){