Hi All, The problem is that i want to have a date and time field in the database but the problem is that this is a part of the form which adds information in the database like name address etc could u tell me how can i add date&time i the database but this the user does not enter it should be automatically entered after the user had filled in the name , address etc.sould u plz tell me
thnaks amitabh
Dear Amitabh,
You can assign the function which returns the date to one variable, say, $datevalue:
$datevalue = date("Y-m-d hⓂs");
Simply use this variable in the insert command so that the date and time value will be inserted authomatically.
If you want to read more, contact this site http://www.mysql.com/doc/D/A/DATETIME.html Solomon
Close, but no cigar.
Use the 'now()' statement in SQL:
INSERT INTO table (date_field) VALUES(now());
Have you tried now() is a predefined function in PHP?
thank you
It works. Thank you for your input,
Solomon
Dude
This method does not work and the earlier method puts in the information but it put the time 45 min back why is that itn doesnt put in the current time i am trying this out on the localhost
It is better to use NOW(). I have checked and it works correctly. Solomon
(field1, field2, datefield) values($value1, $value2, NOW());