Ruby Question

How to sort CSV column data

I have a weird column of start dates that I have to sort according to earliest to latest.

However, I don't know how to interpret the current numbers.

Here are a few examples:

1365985819
1441584686
1397661886
1472340552


Why are the dates like that? How do I convert to "normal" dates so I can sort it?

Answer

They look like Unix time stamps. You can convert them to a readable format. before putting them into a DB or just use them that way and convert on viewing. Sorting smallest to largest will give you older to newer.

To convert them with Ruby use Time.at:

Time.at(1441584686)
  => 2015-09-06 17:11:26 -0700