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: 
leeladhar
Visitor

How to get time part from roDateTime

Hi,

I am trying to do below, I have a date and time string which is in GMT and i want to have that printed in Roku devices timezone.

Here is the code I was trying

datestr = "2010-11-15 04:30:00.000"
dt = CreateObject("roDateTime")
dt.fromISO8601String(datestr)
'GMT Time
print "Date = " + dt.asDateString("long-date") + tostr(dt.getHours()) + ":" + tostr(dt.getMinutes()) + ":" + tostr(dt.getSeconds())
'Local Time
dt.toLocalTime()
print "Date = " + dt.asDateString("long-date") + tostr(dt.getHours()) + ":" + tostr(dt.getMinutes()) + ":" + tostr(dt.getSeconds())

Output I am getting is as below, Our Roku device is set to Eastern TimeZone

Date = Monday November 15, 20104:30:0
Date = Sunday November 14, 201023:30:0

I need to have the time part properly shown above, Am I doing something wrong in getting time ??
0 Kudos
2 REPLIES 2
RokuMarkn
Visitor

Re: How to get time part from roDateTime

Looks mostly ok to me. You need a space or something between the year and the hour, and you probably want to ensure that the minutes and seconds are zero padded to two digits if they're less than 10.

--Mark
0 Kudos
leeladhar
Visitor

Re: How to get time part from roDateTime

Oh, Thanks, my mistake didn't look over on that.

leeladhar
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.