tags:

views:

93

answers:

3

I have a date/time field from a shopping cart API feed, but I don't know what format it is in and I don't have access to the database.

What could [1252457867] be for a date? These dates are all within the last couple weeks

Any ideas?

+7  A: 

This sounds like seconds since the Unix Epoch (January 1, 1970).

Alex B
+13  A: 

Clearly a unix timestamp.

1252457867 = 09 Sep 2009 - 02:57:47

KiNgMaR
+2  A: 

That looks like seconds elapsed since Jan. 1st, 1970 12:00AM.

Use this function to get the date:

var baseDate = new DateTime(1970, 1, 1, 0, 0, 0);
var transactionDate = baseDate.AddSeconds(1252457867);

This will output {9/9/2009 12:57:47 AM} PST

**EDIT: ** If you need UTC:

var utcDate = baseDate.AddSeconds(1252457867).ToUniversalTime();

This outputs {9/9/2009 7:57:47 AM}

--Adam

adamisnt
Now we have 02:57:47 and 12:57:47 AM ...
Daniel Brückner
Daniel Brückner: The reason of the three hours difference is of course that Unix timestamps are in UTC but the .NET Framework converted the date to adaminst's local timezone.
DrJokepu