Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

wrong values for timeZoneOffset

We are seeing erroneous timeZoneOffSet values being sent from some of the client Roku boxes. These values are outside the range of -720 to +720 (12 hours). The timeZoneOffset is calculated as follows
nowDate = CreateObject("roDateTime")
UTCDateHour = nowDate.getHours()
localDateHour = nowDate.getHours()
timeZoneOffset = (UTCDateHour - localDateHour) * 60

I've tested the above code on my local Roku box with all different time zone settings and the above function seems to be working correctly. I was wondering if the above issue was because the client has not set the time on their Roku boxes. Does the Roku box automatically set the timezone correctly or should this be done by the client specifically? If the client does not set the time, what is the default value set on the Roku box?

0 Kudos
Roku Employee
Roku Employee

Re: wrong values for timeZoneOffset

Hi, the user sets the time zone when they set up the device the first time. Relocating the device to another time zone or choosing the incorrect one during setup might cause it provide inaccurate data. I believe devices default to Eastern Standard Time, at least when configured in North America.

- Joel
0 Kudos
Level 11

Re: wrong values for timeZoneOffset

The reason you are getting time difference outside of [-12, +12] is that toLocalTime() conversion may cross midnight back or forth, i.e. into the next or previous day. So you easily get difference swinging [-23, +23].
0 Kudos