bathejasumeet
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015
05:03 AM
Offset from UTC
is there a way to get the offset of time from UTC in BrightScript? something similar to javascript getTimezoneOffset() http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp ?
5 REPLIES 5
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015
08:50 AM
Re: Offset from UTC
"bathejasumeet" wrote:
is there a way to get the offset of time from UTC in BrightScript? something similar to javascript getTimezoneOffset() http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp ?
dt = CreateObject ("roDateTime")
utcHours = dt.GetHours ()
dt.ToLocalTime ()
localHours = dt.GetHours ()
utcOffset = localHours - utcHours

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015
09:25 AM
Re: Offset from UTC
That's a good approach, but it doesn't properly handle timezones which are offset from GMT by a non-integral number of hours. Better to use AsSeconds() rather than GetHours().
--Mark
--Mark
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015
09:41 AM
Re: Offset from UTC
I was just thinking the same thing, and was just changing my reply as you responded:
dt = CreateObject ("roDateTime")
utcSeconds = dt.AsSeconds ()
dt.ToLocalTime ()
localSeconds = dt.AsSeconds ()
utcSecondsOffset = localSeconds - utcSeconds
utcHoursOffset = utcSecondsOffset / 3600
bathejasumeet
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015
10:16 AM
Re: Offset from UTC
Thanx a lot, the approach worked 🙂
chaklasiyanikun
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2020
09:24 AM
Re: Offset from UTC
@belltown wrote:
I was just thinking the same thing, and was just changing my reply as you responded:
dt = CreateObject ("roDateTime")
utcSeconds = dt.AsSeconds ()
dt.ToLocalTime ()
localSeconds = dt.AsSeconds ()
utcSecondsOffset = localSeconds - utcSeconds
utcHoursOffset = utcSecondsOffset / 3600
that's tick is good. Now, Direct method available for offset GetTimeZoneOffset(). But, some times time differences found 4.5 or 3.5. So, How to convert 3.5 to 3 hours 30 mins or 4.5 to 4 hours 30 mins.