KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
It seems that JavaScript's Date() function can only return local date and time. Is there anyway to get time for a specific time zone, e.g., GMT-9? Combining @Esailija and @D3mon-1stVFW, I figured it out: you need to have two time zone offset, one for local time and one for destination time, here is the working code: var today = new Date(); var localoffset = -(today.getTimezoneOffset()/60); var destoffset = -4; var offset = destoffset-localoffset; var d = new Date( new Date().getTime() + offset * 3600 * 1000) An example is here: http://jsfiddle.net/BBzyN/3/
Tags (comma-separated)
Save Edits
Cancel