Im new to php and not sure how to operate with the string or date. I have custom month names, stored in array:
$months = ['1' => 'my Jan', '2'=>'my Feb', '3'=>'my Mar', '4'=>'my Apr', //etc.];
I'd like to show the date with these month names, currently I show:
date_format(new DateTime($route->start_date), 'd F Y')
which gives 01 January 2016
I need to get 01 my Jan 2016
.
Thanks
hope this will help.
<?php
$months = ['1' => 'my Jan', '2'=>'my Feb', '3'=>'my Mar', '4'=>'my Apr'];
$date = new DateTime($route->start_date);
echo '<br>'.$date->format('d').' '.$months[$date->format('n')].' '.$date->format('Y');
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.