Roku Developer Program

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

ToISOString() return wrong date time

Hi,

Working on time based application, when reset the device and launch our application instant, we are getting wrong date and time instead of current date and time.
date = CreateObject("roDateTime")
print date.ToISOString()


Output is "2019-01-09T02:59Z" instead of "2019-02-12T10:42Z", showing approximate 34 days previous static date every time.
But if we restart the device and launch the application after internet connection, then we are getting correct date and time.

Please suggest the solution for this problem.

Thanks in advance,
Simran 
0 Kudos
5 Replies
renojim
Level 8

Re: ToISOString() return wrong date time

There is no solution. The box doesn't have a battery backed-up RTC. I doesn't know the correct date/time until it establishes an Internet connection and contacts an NTP server. If your app can't operate without the correct time, you either have to wait for Internet connection to be established or exit if the connection hasn't been established. You can't rely on roDateTime unless the box is able to contact the Roku NTP server.

-JT
0 Kudos
destruk
Level 10

Re: ToISOString() return wrong date time

Perhaps you can check for the date/time, and if it is the default date you receive when there isn't an internet connection available, simply not use the data and check it again later in the application.
Although why your device would require the internet but not be able to access the date/time server, sounds like a critical flaw in your internet routing service/gateway/proxy maybe?
0 Kudos
simranjit
Level 7

Re: ToISOString() return wrong date time

"renojim" wrote:
There is no solution.  The box doesn't have a battery backed-up RTC.  I doesn't know the correct date/time until it establishes an Internet connection and contacts an NTP server.  If your app can't operate without the correct time, you either have to wait for Internet connection to be established or exit if the connection hasn't been established.  You can't rely on roDateTime unless the box is able to contact the Roku NTP server.

-JT

Thanks 
0 Kudos
simranjit
Level 7

Re: ToISOString() return wrong date time

"destruk" wrote:
Perhaps you can check for the date/time, and if it is the default date you receive when there isn't an internet connection available, simply not use the data and check it again later in the application.
Although why your device would require the internet but not be able to access the date/time server, sounds like a critical flaw in your internet routing service/gateway/proxy maybe?

Thanks, we will look into internet routing service.
0 Kudos
destruk
Level 10

Re: ToISOString() return wrong date time

If your content list json or xml is generated in realtime on the server via a script, you could have the server provide the time in that file when it is sent to the Roku (as a time from epoch in seconds), or simply run a php script on the server to return the data separately, and then you could start a timer service on the Roku and add both together to get the time without using the Roku time server.  Just another 'solution'.
0 Kudos