Click to See Complete Forum and Search --> : Convert Date from 01-12-2007 to 2007-12-01 ?


sanchez_1960
05-31-2007, 05:38 AM
Hi,

Previously when enterting into a my database, I use to use drop down selections and then combine the values to the 2007-12-01 format for MySQL and then output as DATE_FORMAT in SQL to switch it back around again.

However, I've now switched to a Java calendar on my input screens. So I want to convert 01-12-2007 for example to 2007-12-01 . Is there any prewritten functions for this, or do I need to write one myself?

MrCoder
05-31-2007, 06:00 AM
$date = "2007-12-01";
$new_date = implode("-", array_reverse(explode("-", $date)));

sanchez_1960
05-31-2007, 06:28 AM
lol, didn't realise it'd be that simple!

Thank you very much!