Home > Archive > MySQL Server Forum > June 2005 > datetime and timestamp recording different times









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author datetime and timestamp recording different times
anagai

2005-06-06, 8:23 pm

I have a datetime field that records date and time. This field records
when rec is created. I also have a timestamp field that records
whenever the record is updated. I noticed that when i first create the
record, the update time is about 3-5 minutes before the create time.
The update time and create time has to be identical. How can one lag
the other? Im executing sql from a php page.

Gordon Burditt

2005-06-08, 8:23 pm

>I have a datetime field that records date and time. This field records
>when rec is created. I also have a timestamp field that records
>whenever the record is updated. I noticed that when i first create the
>record, the update time is about 3-5 minutes before the create time.
>The update time and create time has to be identical. How can one lag
>the other? Im executing sql from a php page.


How do you create the record? If you do something like:

INSERT INTO record values (created, modified) VALUES
('2005-6-8 16:02', null);

the 'created' field gets the current time from the CLIENT computer
(which formatted the '2005-6-8 16:02' string somehow), and the
modified field gets the current time from the SERVER computer.

In this case you could use:
INSERT INTO record values (created, modified) VALUES
(now(), null);
which would use the server clock for both.

Gordon L. Burditt

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com