Forum: Ruby Convert unix time to 2012-12-18 18:59:22 (sample)

9f92628a418834138598372d43213883?d=identicon&s=25 robert lengu (robertlengu789)
on 2012-12-18 20:50
Hi
i am trying to find out how to convert

bellow 1355354837
to something  like

2012-12-13 01:23:27

in linux from command line ,

date -d @1355354837
Wed Dec 12 23:27:17 GMT 2012
i dont need the GMT


but how can i get that by using ruby time module

i went through the google but i am not geting any luck

Thanks
9f92628a418834138598372d43213883?d=identicon&s=25 robert lengu (robertlengu789)
on 2012-12-18 20:55
Ok i found one way

puts Time.at(1355841956)

but its gives

Tue Dec 18 14:45:56 +0000 2012

but i want like thsi

2012-12-13 01:23:27
3853dd5371ac1e094fc45d6c2aa0e459?d=identicon&s=25 Carlo E. Prelz (Guest)
on 2012-12-18 21:01
(Received via mailing list)
Subject: Re: Convert unix time to 2012-12-18 18:59:22 (sample)
  Date: Wed 19 Dec 12 04:55:50AM +0900

Quoting robert lengu (lists@ruby-forum.com):

> 2012-12-13 01:23:27
Look at

ri Time#strftime

for instructions about how to format time the exact way that you want.

Carlo
9f92628a418834138598372d43213883?d=identicon&s=25 robert lengu (robertlengu789)
on 2012-12-18 21:44
Thanks, got the solution
87e61e351b823e19b4a62a896d2af0d4?d=identicon&s=25 Henry Maddocks (Guest)
on 2012-12-18 22:12
(Received via mailing list)
ri strftime

Henry
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.