DMXzone Database Connector PHP Support Product Page

Solved

"now" keyword incorrectly saving time in SQL datetime field

Reported 26 Nov 2014 09:00:27
1
has this problem
26 Nov 2014 09:00:27 George Mann posted:
I am using a datetime field in a SQL database to keep track of when a user updates a record. I have the DMXZone Database Connector updating the record and I set the value of the field to "now." When the record updates, the datetime field is 9 hours ahead of local time. I am UTC - 7, so this doesn't even make sense with time zones. If I use the old PHP database connector built into DMX, the datetime is updated correctly even with my time zone.

Official Solution

Replied 27 Nov 2014 09:20:29
Well,
It seems to me your server timezone is set to something +9hours ahead of your location
You can tell PHP to use your time-zone by setting the proper value of “date.timezone” in php.ini.
Change this : date.timezone = "UTC"
To your location from the list:
php.net/manual/en/timezones.america.php

For example, if you are located on the west coast, change it to: date.timezone = "America/Los_Angeles" etc..

Replies

Replied 26 Nov 2014 09:14:41
26 Nov 2014 09:14:41 Teodor Kuduschiev replied:
Hello George,
What is the database type you are using?
Also - is this 9 hours difference between he user and the server time?
Replied 26 Nov 2014 23:38:15
26 Nov 2014 23:38:15 George Mann replied:
I am using WAMP (Apache and mySQL) for the database. The 9 hour difference is between my computer (server) time and the time that is stored in the database.
Example:
If I update a record at 1pm actual time, the database shows an update time of 10pm. The date is correct unless it spans over midnight (i.e. updated at 10pm 11/26/14, database shows 7 am 11/27/14).
Replied 27 Nov 2014 09:20:29
27 Nov 2014 09:20:29 Teodor Kuduschiev replied:
Well,
It seems to me your server timezone is set to something +9hours ahead of your location
You can tell PHP to use your time-zone by setting the proper value of “date.timezone” in php.ini.
Change this : date.timezone = "UTC"
To your location from the list:
php.net/manual/en/timezones.america.php

For example, if you are located on the west coast, change it to: date.timezone = "America/Los_Angeles" etc..
Replied 27 Nov 2014 10:59:45
27 Nov 2014 10:59:45 George Mann replied:
Well... I could have sworn I changed that. The time zone was set to Paris (9 hours ahead of me). Thanks for the response.

Reply to this topic