Parsing date like 1240915075 Parsing date like 1240915075 ruby ruby

Parsing date like 1240915075


This is UNIX time (sometimes called Epoch time). It measures the number of seconds elapsed since January 1, 1970 (The Unix epoch is the time 00:00:00 UTC on 1 January 1970)

Here's an example converter: http://www.esqsoft.com/javascript_examples/date-to-epoch.htm

A stackoverflow question regarding converting integer time using Ruby: Ruby / Rails: convert int to time OR get time from integer?

use the Time.at function to convert e.g.:

t = Time.at(i)


That's Epoch Time (the first one corresponds to Tue Apr 28 2009 11:37:55 GMT+0100).

You can get a datetime out of it, using Time.at, like this:

Time.at(1240915075)


That is a unix timestamp - the number of seconds since jan 1st 1970.

An example of how to use it in Ruby is here:

t = Time.at(1215163257)puts t.to_date>> 2008-07-04