I have been working further with date and time in mysql and discovered a strange problem. When I run the following query it puts the current datetime into the table fine:

insert into table values ('',SYSDATE())

However, when I try to put in a different date, for example, 10 minutes (600 seconds) from the current time with the following query it irecords only 6 minutes ahead, not ten. It appears that PHP treats minutes as 100 seconds long.

insert into table values ('',SYSDATE()+600)

I have searched the mysql site and others with no success. Does anyone know more about this?

Damien.

    Well, this isn't PHP's doing. PHP is doing nothing more than sending the SQL query as-is to MySQL. My thinking is that you would probably have better luck calculating the date through PHP though. It just has more control methinks

      Thanks, I did realize the problem was within the mysql so I have written a function to calculate first. It would have been simplier the other way though. I also found that it was unrealiable using SYSDATE()+600 as most of the time the database change the value to 0000-00-00 0000:00:00.

      Quite frustrating.

      Thanks.

        Write a Reply...