Click to See Complete Forum and Search --> : Simple Date Question


pj-away
10-14-2003, 05:44 AM
What is the best way to deal with this ?

I have users who want to enter a date in the Format DD/MM/YYYY. (via a form)

I need to check the date is valid and then format it to inset it into a mysql database which wants it in the format YYYY/MM/DD

Please could someone give me a good example of how to do this - I sure its simple - but I can get my head round this one today

PJ

pyro
10-14-2003, 07:08 AM
There are actually a few ways you could do this, but this is probably the easiest:

$date = "10/14/2003";
list($month, $day, $year) = explode("/", $date);
echo $year."/".$month."/".$day;

pj-away
10-14-2003, 08:25 AM
Thanks pyro

pj

pyro
10-14-2003, 09:28 AM
Sure thing... :)