Convert era to Ruby

Is there an easy way to convert Epoch time to standard format with Ruby? If so, can I customize the way it is displayed?

+8
linux ruby
source share
1 answer

Use the Time.at method:

 Time.at(1234567890) #=> 2009-02-13 16:31:30 -0700 

To display the time, you can use the strftime method for the resulting object.

For example:

 Time.at(1234567890).strftime("%m/%d/%Y") #=> "02/13/2009" 
+21
source share

All Articles