Jump to content

Formatting output date


Recommended Posts

Hi all


I have a PHP script with the following var


print $date;


at the moment it is formatting the date like




is it possible to get PHP to switch the date and month, so it looks like





Link to comment
Share on other sites

You swap the month with days like so

list($month, $day, $year) = explode('-', $date);
$new_date = "$day-$month-$year";

print $new_date;


Alternatively your can format the date to 24th March 2010 using this

$new_date = date('jS F Y', strtotime($date));
print $new_date;

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.