This project is read-only.

How to Convert Column Timestamp to C# DateTime?

Oct 17, 2011 at 8:45 PM

Hey guys, 

can anyone help me to understand how can I convert Column.Timestamp back to DateTime?



Oct 18, 2011 at 9:15 AM
Edited Oct 18, 2011 at 9:15 AM

I think you can get DateTime by next code.


// convert micro second to 100 nano second and plus epoch time 
var datetime = new DateTime(Column.Timestamp * 10) + new DateTime(1970, 1, 1); 

I haven't test this code. Try it for yourself.

Oct 18, 2011 at 12:50 PM

Hi Sabro, thanks for you help.

I tested your code but it didn´t worked, but thanks to you I could understand the logic and I finally found a code that works:

static DateTime ConvertFromUnixTimestamp(double timestamp)
     return new DateTime((long) timestamp * 10).AddYears(1969).ToLocalTime();

This worked fine, you guys can use this on next version if you like.

Thanks again :)

Oct 18, 2011 at 2:35 PM

I am happy that you sloved problem. If we implement it on next version, I will write following method.

static DateTime GetDateTime(long unixtime)
static DateTime GetDateTimeUtc(long unixtime)
static DateTime GetDateTimeLocal(long unixtime)

I make work item.

Oct 18, 2011 at 2:41 PM

What a great idea ..

I hope you guys can continue with this great job ... and please let me know if there is something I can help.