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

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

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

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 ([email protected]):

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

Thanks, got the solution

ri strftime

Henry

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs