Last Updated: September 30, 2021
· boris

Unix time to " human time" in Ruby

Today, looking at out slowquery.log I found this line SET timestamp=1377554362; and thought about this pro-tip: How to convert that timestamp to human readable time, using ruby? It's quite easy:

➜  ~  irb
irb(main):001:0> require 'date'
=> true
irb(main):002:0> DateTime.strptime("1377554153",'%s')
=> #<DateTime: 2013-08-26T21:55:53+00:00 ((2456531j,78953s,0n),+0s,2299161j)>

Now I know that 1377554362 is 2013-08-26T21:55:53 :)