converting Unix datetime count to .Net DateTime object

  • Thread starter Thread starter Mark Worrall
  • Start date Start date
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
 
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
 
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
 
Back
Top