February 8th, 2000, 01:26 PM
I want to store the current time in a mysql database with php. I would like the format to be:
but any format will do for now.
If it doesn't work in php, can I get the date/time with a perl script?
February 8th, 2000, 01:54 PM
You don't need to. Check out the DATETIME datatype for mysql. It stores and retrieves in two formats. A string "YYYY-MM-DD HH:MM:SS" or as an interger YYYYMMDDHHMMSS
February 8th, 2000, 03:15 PM
I want to compare the current date with the one stored in the mysql database to check time difference. How do I do that?
February 9th, 2000, 09:19 AM
You can use the mysql date/time functions, specifically date_add() and date_sub().
Let's say you want the records where date is less than 7 days old.
select * from table where date_add(date_field, interval 7 day)> now();
See the mysql manual for more detail