Choose Language Hide Translation Bar
Highlighted
FN
FN
Community Trekker

How to get the timezone from user's computer/laptop

Which will be the best or simpler way to get the current UTC time (including timezone) of the user running JMP?

 

 

 

 

 

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How to get the timezone from user's computer/laptop

This is UTC Time:

request = New HTTP Request(
	URL("google.com"),
	Method("GET")
);
request << Send;
headers = request << Get Response Headers();
show(headers["date"]);

headers["date"] is a JSL Date object in UTC

so the timezone offset would be:

utc = headers["date"];
Hour(today()) - Hour(utc);

 

View solution in original post

6 REPLIES 6
Highlighted

Re: How to get the timezone from user's computer/laptop

Hi,

 

There is a post on the community here that might be able to help: https://community.jmp.com/t5/Uncharted/UTC-Time-Zone/ba-p/28942.

Highlighted

Re: How to get the timezone from user's computer/laptop

This is UTC Time:

request = New HTTP Request(
	URL("google.com"),
	Method("GET")
);
request << Send;
headers = request << Get Response Headers();
show(headers["date"]);

headers["date"] is a JSL Date object in UTC

so the timezone offset would be:

utc = headers["date"];
Hour(today()) - Hour(utc);

 

View solution in original post

Highlighted

Re: How to get the timezone from user's computer/laptop

BTW... you can use any url. Routers/switches use UTC time.

0 Kudos

Re: How to get the timezone from user's computer/laptop

This might be a little better, so it won't miss the boundaries

utc = headers[ "date" ];
tz = Date Difference (utc, today (), "hour" );
show (tz);
Highlighted
FN
FN
Community Trekker

Re: How to get the timezone from user's computer/laptop

Thanks Bryan, could you please edit your previous post with the improved code? I am accepting this as solution.

0 Kudos
Highlighted

Re: How to get the timezone from user's computer/laptop

request = New HTTP Request(
	URL("google.com"),
	Method("GET"),
);
request << Send("blob");
headers = request << Get Response Headers();
utc = headers["date"];

tz = round((today() - utc)/inhours(1));
show(tz); 
 

This should be the complete script.