Roku Developer Program

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

Unix Timestamp to Readable format

Does anyone know how to convert a unix timestamp "1460400862" to a readable datetime. I have looked through the sdk and could not find anything but I may have just missed something. Thanks in advance for any help.
7 Replies
TheEndless
Level 9

Re: Unix Timestamp to Readable format

date = CreateObject("roDateTime")
date.FromSeconds(timestamp)
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
bcaudill302
Level 8

Re: Unix Timestamp to Readable format

Thanks, that did it. For some reason I didn't think that would work. Oh well, guess I was over complicating it. Thanks again.
ajitg_4557
Level 7

Re: Unix Timestamp to Readable format

.....
0 Kudos
ajitg_4557
Level 7

Re: Unix Timestamp to Readable format

Please make me understand....where i am doing mistake. Here is my code.

Fill_time=json.FlightInfoExResult.flights[0].filed_time
Fill_time1=Fill_time.ToStr()
Fill_time2=Fill_time1.trim()
now_ok=StrToI(Fill_time2)
date = CreateObject("roDateTime")
EpochToHumanReadableTime=date.FromSeconds(now_ok)
Print"EpochToHumanReadableTime========>>>>>>"EpochToHumanReadableTime

on Telnet i am getting:-
Print"EpochToHumanReadableTime========>>>>>>"<UNINITALIZED>
0 Kudos
renojim
Community Streaming Expert

Re: Unix Timestamp to Readable format

Add more prints (after every statement if you have to).
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
developer34
Level 8

Re: Unix Timestamp to Readable format

i tried the same thing but it is always showing in telnet <UNINITIALIZED>

sub timeConverter()
   
    date = CreateObject("roDateTime")
    seconds = date.FromSeconds(1460400862)
    ?seconds
end sub


i am trying to call the function from init()

Please tell me what i am doing wrong

0 Kudos
renojim
Community Streaming Expert

Re: Unix Timestamp to Readable format

You're setting seconds to the return value of a function that doesn't return a value, hence the <UNINITIALIZED>.  I'm not sure what you're trying to do since you already know the seconds (1460400862).  You could do this, but it doesn't get you anywhere:

date = CreateObject("roDateTime")
date.FromSeconds(1460400862)
seconds = date.asSeconds() ?seconds

-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