Page 1 of 1

Converting Date format

Posted: Wed Aug 11, 2010 8:15 pm
by webphotogeek
Can someone tell me how I go about changing a date, such as 08/11/12 to the European format in MySQL so that I can save it to the database. The date column is in type Date.

Thanks :banghead:

Re: Converting Date format

Posted: Wed Aug 11, 2010 8:45 pm
by John Cartwright

Code: Select all

echo date('Y-m-d', strtotime('08/11/12'));

Re: Converting Date format

Posted: Thu Aug 12, 2010 6:51 am
by webphotogeek
Thanks, but I'm still a little confused as to how to incorporate this function into the Insert statement. The date is actually a variable and I'm capturing it here: $date = $_POST["date"]; then using this MySQL statement here: $pur="INSERT INTO Purchasing(ID, Item, Description, Quantity, Price, Date, AMPM)VALUES('$cust_id','$item_a','$description_a','$quantity1','$price1','$date','$ampm')";

Also, when I ecohed it, it came back as the 8/11/10 and not 2010-08-10.

Sorry if this sounds elementary. I just started getting back into PHP after a few years.

Thanks for your help!