oneofakind
oneofakind

Reputation: 562

Extjs 4 Date - Change Timezone

Simple question, as the title say, how do I change the timezone of the Date object in Extjs 4?

Using:

 var today = new Date()

gets the date of a PC not the server so I have to change the timezone every time I use that line of code. Sadly I have not seen any setTimezone() methods.

How do I do this?

Upvotes: 0

Views: 2164

Answers (3)

Martin Stein
Martin Stein

Reputation: 305

You are missing something. The Date object does not hold a timezone. The timezone comes into play when you want to display the date. When you convert a date into a string you need to give it the location on earth that you want to format the output for. In Java that's the SimpleDateFormat or somesuch class. If you were born at 6AM in New York it was 3AM in San Francisco at the time. Your Date object will be the same, but the output string will be different depending on location.

Upvotes: 1

harry
harry

Reputation: 702

There you go: www.datejs.com

This framework already include the method you need! If you don't want to include the whole framework, just copy out what you need.

Upvotes: 0

Avinash T.
Avinash T.

Reputation: 2349

Instead of changing timezone every time, Create your own Date class which will have implementation to add or subtract timezone according to account settings.

Upvotes: 0

Related Questions