Skip to content
Advertisement

Tag: timezone

JavaScript check if timezone name valid or not

Is there a way to check if timezone name valid or not in JavaScript without using external library? When user enters timezone name in text field I want to verify whether zone is valid or not? I know we can do it easily using moment-timezone library. But I don’t want to use any extra library. I’m looking for pure JavaScript

MomentJS set timezone without changing time

I’m trying to set the timezone for a date in moment.js without changing the time value I get a date in utc: and I need to set the time zone without changing the time. if I use date.utcOffset(moment().utcOffset()) it adds the offset: I could do but that seems like an inefficient way to do it. Is there any method that

Convert date to another timezone in JavaScript

I am looking for a function to convert date in one timezone to another. It need two parameters, date (in format “2012/04/10 10:10:30 +0000”) timezone string (“Asia/Jakarta”) The timezone string is described in http://en.wikipedia.org/wiki/Zone.tab Is there an easy way to do this? Answer Here is the one-liner: This is the MDN Reference. Beware the caveat: function above works by relying

Convert UTC date time to local date time

From the server I get a datetime variable in this format: 6/29/2011 4:52:48 PM and it is in UTC time. I want to convert it to the current user’s browser time zone using JavaScript. How this can be done using JavaScript or jQuery? Answer Append ‘UTC’ to the string before converting it to a date in javascript:

Getting the client’s time zone (and offset) in JavaScript

How can I gather the visitor’s time zone information? I need both: the time zone (for example, Europe/London) and the offset from UTC or GMT (for example, UTC+01) Answer Using getTimezoneOffset() You can get the time zone offset in minutes like this: The time-zone offset is the difference, in minutes, between UTC and local time. Note that this means that

Advertisement