I’m trying to insert the current date from a php form into a database.
My query is:
$sql3="INSERT INTO orderDetails (compName, package, cost, date) VALUES ('$companyName', '$package', '$cost_record', 'date()')";
This produces the following: 0000-00-00 00:00:00 which obviously isn’t right.
Can anyone recommend how to get this to display the correct date/time?
Also, I need it in the following format: yyyymmddhhmmss – Is this possible? How would I go about it?
Thanks!
You should use php’s function
time()or mysql’sUNIX_TIMESTAMPthis is anint(11)and used like so:Then you create a visual timestamp from php using the
date()function.. during your loop in PHP.