derChris
derChris

Reputation: 890

Get wrong timezoneOffset in AIR/Flex/AS3

in Germany I get on my PC:

new Date().getTimezoneOffset(); //-60

new Date().timezoneOffset //-60

But as my PC shows me correctly I am in UTC+01:00 which is the correct timezone for Berlin, Amsterdam...

How can I fix this?

Kind regards

Christian

Upvotes: 0

Views: 213

Answers (2)

gbdcool
gbdcool

Reputation: 982

getTimezoneOffset() returns the difference, in minutes, between universal time (UTC) and the computer's local time as per http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html#getTimezoneOffset().

If UTC time is 3:00pm then your local time is 4:00pm. Then the difference is -60 minutes which is calculated as below:

3:00 - 4:00 = -60 mins.

Upvotes: 1

Philarmon
Philarmon

Reputation: 1806

As stated in the documentation getTimezoneOffset() returns "The minutes you need to add to the computer's local time value to equal UTC. If your computer's time is set later than UTC, the return value will be negative.".

So -60 IS the time you have to add to the computer's local time to get UTC when you are in the UTC+1 timezone :)

Upvotes: 1

Related Questions