tags:

views:

68

answers:

3

I have a timestamp exported from a program that I'm not sure how to convert programmatically using c#

I can get more examples if required

any pointers would be appreciated

1280833200 == 3 aug 2010 12:00

thanks,

Mark

+6  A: 

isnt that the datetime in ticks Unix time?

edit: yes it is: http://www.epochconverter.com/

You can make a DateTime by adding those seconds to a new date.

DateTime d = new DateTime(1970, 1, 1, 0, 0, 0)).AddSeconds(1280833200)
Stefanvds
The "ticks" in a .NET timestamp are "the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar" according to http://msdn.microsoft.com/en-us/library/z2xf7zzk.aspx, which is not the same measurement or epoch as a Unix timestamp.
Bob
Nope, a tick is 100 nanoseconds, and the 'epoch' is the year 1. 1280833200 is a Unix timestamp (seconds since midnight on 1970-01-01).
Richard Fearn
@p.campbell why did you edit a wrong answer to fix it instead of just upvoting a correct answer?
Bob
+2  A: 

This is a Unix timestamp; number of seconds since Jan 1, 1970. You can convert like:

DateTime epoch = new DateTime(1970,1,1);
DateTime ts = epoch.AddSeconds(1280833200);
Bob
thanks, just too slow :-)
foz1284
@foz I think I beat Richard by about 30 seconds, actually . . . but I'm glad you accepted a correct answer :)
Bob
not sure, I remember seeing yours said it was a minute later! anyhow, thanks to both of you.
foz1284
+3  A: 

It's Unix time - the number of seconds since midnight UTC on 1st January 1970. You can use this site to convert the timestamp to an ordinary date and time.

As for conversion in C#, this should work:

double timestamp = 1280833200;
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
dateTime = dateTime.AddSeconds(timestamp);
Richard Fearn
Cheers, First CORRECT answer :-) much appreciated
foz1284