cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Choose Language Hide Translation Bar
FN
FN
Level VI

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?

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

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.

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);

 

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

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

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);
FN
FN
Level VI

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.

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.