Forum Discussion

leeladhar's avatar
leeladhar
Visitor
15 years ago

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 ??

2 Replies

  • 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