언어 설정

Menu
Sites
Language
WEB API 2.3.1+ CORRECTLY DETECT GMT OFFSET, HOW ?

HOW CORRECTLY AND SIMPLY DETECT LOCAL GMT OFFSET ?

 like 0, -2 or +9  etc from UTC( GMT 0) with  WEB API 2.3.1+

 

THANK YOU

Responses

12 댓글
André Reus

Use getTimezoneAbbreviation() to get the TimeZoneAbbreviation. 

Like, 

var abb = current_time.getTimezoneAbbreviation();
console.log (abb);

It will give you (based on your zone)

GMT+9

 

Denis Miroshnikov

NO , I know it , but I need not NAME of ZONE in GMT format, but i need OFFSET someting like +9 of -1 w/o parsing this string into number (((

André Reus

You have to trim the String to get your desired format. Don't expect all the API is ready to use in your own requirement. 

Denis Miroshnikov

ehhh (

 why not?   I think is good function for candidate to incude in API ?

André Reus

You need to get the substring of the produced string. 

Try like this, 

var abb = current_time.getTimezoneAbbreviation();
var res= abb.substring(3);
console.log (res);

And you will get your desired output. 

-Thanks 

Denis Miroshnikov

is it  no good solution bacause we have GMT +5:30  for ex .. and we need parse HH and MM  ! and + or -


 

André Reus

So what ? 

+6.30 Rangoon

+9 Seoul

-4.30 Caracas(USA)

Denis Miroshnikov

Yes Yes , You do  (parse HH)+(ParseMM) ?

 

André Reus

Code is already given !!!! 
I have just changed the TimeZone to show you !!! -_-  

Denis Miroshnikov

Mean this code ?

var abb = current_time.getTimezoneAbbreviation();
var res= abb.substring(3);
console.log (res);
Denis Miroshnikov

How You change time zone?  because in EMULAOR i can't do it


 

André Reus

I am using Real device.