Reputation: 2801
I am storing a timestamp into my database based on the America/Chicago
timezone in PHP. The problem is, whenever I return the time and compare it with new Date()
in javascript, the PHP
versioning of Date
is 7 minutes behind. They are both the same time zone central time
. Here is an example output from the server and the current:
Sun Apr 10 2016 14:20:41 GMT-0500 (CDT) -> PHP
Sun Apr 10 2016 14:27:53 GMT-0500 (CDT) -> JavaScript
Suggestions?
Upvotes: 0
Views: 40
Reputation: 1178
If you need to compare timestamps generated by your code, you need to ensure both timestamps are generated on the same machine. So you either need to generate both on the client machine, or both on the server machine. If you generate one on the client and one on the server, then they will not compare correctly if the clocks on the client and server have not been perfectly synchronized.
Upvotes: 1