Get current timestamp from specific timezone

Toby picture Toby · Mar 6, 2012 · Viewed 13.9k times · Source

is there an easy way to get the unix timestamp in javascript from a specific timezone? for example i want the client send me an unix timestamp but i want to get it to match my timezone.

thanks!

Answer

tjdett picture tjdett · Mar 6, 2012

Why not simply send the date in UTC, and then convert to your timezone on the server?

var utcEpochSeconds = dateObj.getTime() + (dateObj.getTimezoneOffset() * 60000);