Im having the hardest time trying to convert client side time to server time. The reason is I have a cron job executing once every hour. I manage to get the timezone offset in java script, but I’am clueless on how to apply the timezone offset. For instance, my timezone offset is 7. Ok!? than what? How should I apply this offset?
To get the offset I use
var offset = new Date().getTimezoneOffset();
Server side is handled by php.
As others have said in the comments, the best approach is using a UNIX timestamp. To get this in JavaScript, use the following code:
getTimereturns a value in milliseconds, but we want that value in seconds, so we divide it by 1000.You can then either use AJAX to send that value to the server or put the value in a hidden form field and have it sent to the server when the user submits the form.
In PHP, you can get the date like this: