johnrb87 Posted August 8, 2010 Share Posted August 8, 2010 Hi all I have a PHP script with the following var print $date; at the moment it is formatting the date like 03-24-2010 is it possible to get PHP to switch the date and month, so it looks like 24-03-2010 Thanks Link to comment https://forums.phpfreaks.com/topic/210138-formatting-output-date/ Share on other sites More sharing options...
kla0005 Posted August 8, 2010 Share Posted August 8, 2010 $date = date("d-m-Y"); Like that? Link to comment https://forums.phpfreaks.com/topic/210138-formatting-output-date/#findComment-1096671 Share on other sites More sharing options...
johnrb87 Posted August 8, 2010 Author Share Posted August 8, 2010 that just seems to print todays date Link to comment https://forums.phpfreaks.com/topic/210138-formatting-output-date/#findComment-1096673 Share on other sites More sharing options...
wildteen88 Posted August 8, 2010 Share Posted August 8, 2010 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 https://forums.phpfreaks.com/topic/210138-formatting-output-date/#findComment-1096676 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.