inserting time into mysql database

Soldato
Joined
1 Feb 2006
Posts
8,188
hi, i am writing a basic cms at the moment and i need to add the current date and time of each post into my database. There will be an option of setting articles to go live at a later date but by default all posts will go online immediately. What I need to know is what is the best way to enter the current date/time into mysql database and what datatype should i specify in the database? Would it be better to use php to get the current time, or is there a mysql function that will set the current time? Thanks
 
The MYSQL function NOW() will get the current timestamp.
Check out the MYSQL manual for what datatype to use as it depends on the accuracy that you want to record.
 
excellent, thanks. Will check it out.

Edit: is it possible to format the date/time sequence in the now() command?
 
Last edited:
jonnyc747 said:
excellent, thanks. Will check it out.

Edit: is it possible to format the date/time sequence in the now() command?

Not sure about using now() directly, but there are loads of possibilities here.
 
Back
Top Bottom