Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
squirreltown
Roku Guru

datetime(solved)

I know i'm missing something silly but can't see it.

thisclock = createObject("roDateTime")
thisclock.tolocalTime()



This is producing GMT time in 24hour mode. The roku is set to 12 hour.
So right now its 5pm (MST) and thisclock.GetHours() is reading 23

Thanks
Kinetics Screensavers
0 Kudos
3 REPLIES 3
renojim
Community Streaming Expert

Re: datetime

At what point are you looking at thisclock.GetHours()? It works for me if I print thisclock.GetHours() right after your thisclock.toLocalTime() statement. If you call thisclock.Mark() at some later point, you'll have to call thisclock.toLocalTime() again. Also, GetHours() will always return a number between 0 and 23 inclusive.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
squirreltown
Roku Guru

Re: datetime

"renojim" wrote:
At what point are you looking at thisclock.GetHours()? It works for me if I print thisclock.GetHours() right after your thisclock.toLocalTime() statement. If you call thisclock.Mark() at some later point, you'll have to call thisclock.toLocalTime() again. Also, GetHours() will always return a number between 0 and 23 inclusive.

-JT



Thank you. I knew it was simple. I was calling local time before the while loop and then only mark during the loop. (floating screensaver clock)
Kinetics Screensavers
0 Kudos
EnTerr
Roku Guru

Re: datetime(solved)

"toLocalTime()" is better to think as "addTimeZone()" - that's all it does.

Say player is set as being on the west coast (PST = GMT-8), then each call will subtract 8 hours (make that 7 since this week) from the time value. Repeated calls will keep subtracting more hours repeatedly (there is a mathemagical warning about non-idempotence). roDateTime does not keep internal flag if that's local or universal timestamp, the function is just a single-direction mutator
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.