Get Iphone Deveice Timezone
Hi,all
I want the value of Iphone Device Timezone set by any user in his/her Iphone using Titanium???
So if anyone finds solutions please do post me ASAP…it will be a great help to me…
Waiting for positive response from someone…
4 Answers
-
Is there any reason standard javascript can't be used for this? I don't see that titanium needs to provide anything at all. For example:
var dt = new Date(); var offset = dt.getTimezoneOffset(); var tz = dt.toString(); // ends with (time zone name) tz = tz.replace(/^.*\(/,""); // Remove leading text through ( tz = tz.replace(/\).*$/,""); // Remove trailing text from ) Ti.API.info(tz + ' is ' + offset + ' minutes from UTC');
-
+1, would like to know if this is possible. I'm pulling down UTC date/time and computing time difference in days/hours. Thanks.
-
I agree with Doug's post, use all JS to get the offset.
What are you planning on doing with it?
If just displaying the name, as suggested parse it out.
If performing a calculation take the value of date.getTimezoneOffset() which is in minutes and multiply into millseconds (60s * 1000ms) before using it.
-
To Ryan's question, you can create a Date object and use the Date.setUTC{*} functions to create your UTC time then you can get the local time from the Date object.