-2

I would like to know how to convert 2015-06-15 to June 15, 2015 in PHP This is essentially the format that it is stored as in mysql, and in how I retrieve it:

$crs_date1 = $row_crs['course_date1'];

then echo it:

echo $crs_date1

but I would rather echo it in a more readable format.

Thanks in advance

code_legend
  • 3,547
  • 15
  • 51
  • 95

2 Answers2

2
echo strftime("%B %m, %Y", strtotime($crs_date1));

Might give you an error (this was just off the top of my head), so the format (first parameter of strftime) could be a bit wrong

Gerton
  • 676
  • 3
  • 14
  • Full month is `F`. `B` is swatch internet time. – Albzi Jun 15 '15 at 13:53
  • what would be %B stand for? thanks in advance. what changes should i make based on your recent comment – code_legend Jun 15 '15 at 13:54
  • %B Full month name, based on the locale January through December list of all things you can add there : http://php.net/manual/en/function.strftime.php – Gerton Jun 15 '15 at 13:56
2

Try this

echo date('F m Y',strtotime($crs_date1));
Toretto
  • 4,721
  • 5
  • 27
  • 46