converting Unix datetime count to .Net DateTime object

M

Mark Worrall

I am being supplied a count of number of seconds since Jan 1st 1970, i.e. a
Unix system time. How can I convert this into a valid .Net DateTime object ?

thanks,
Mark

WinXP / C#.Net 2003
 
M

Mattias Sjögren

Mark,
I am being supplied a count of number of seconds since Jan 1st 1970, i.e. a
Unix system time. How can I convert this into a valid .Net DateTime object ?

Get a DateTime value representing Jan 1st 1970, then call AddSeconds
on it.



Mattias
 
D

Dino Chiesa [Microsoft]

public class Time_t_To_DateTime {
public static void Main() {

int t= 1070390676; // value of time_t
System.DateTime dt= new System.DateTime(1970,1,1).AddSeconds(t);

System.Console.WriteLine(dt);
}
}

ps: no need to cross post
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top