How to reformat date in PHP?

Solution 1:

Unlike the strtotime based examples, this allows you to ensure the month and day are interpreted in the correct order regardless of locale settings specified on the server.

$date = DateTime::createFromFormat('Y-m-d', '2009-08-12');
$output = $date->format('F j, Y');

Solution 2:

date("F d, Y", strtotime($input))

Solution 3:

$new_format = date("Your Date String", strtotime($date));

See:
- http://php.net/strtotime
- http://php.net/date

Basically, if strtotime() can read it correctly, you can reformat it anyway you please.

In this case, Year - Month - Day is a properly recognized strtotime() format, this might not be the case for other formats.