2

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

Gyuzal
  • 1,581
  • 10
  • 52
  • 99

1 Answers1

0

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');

?>
dhanushka
  • 343
  • 3
  • 12