I had a need to convert c++ time_t to C# DateTime and have also had the same need to convert to C# DateTime to c++ time_t.
I hope some of you find these conversions useful
[code]
public static long ToUnixtime(DateTime date){
DateTime unixStartTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); TimeSpan timeSpan = date - unixStartTime; return Convert.ToInt64(timeSpan.TotalSeconds);}
public static DateTime ToCSharpTime(long unixTime){
DateTime unixStartTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); return unixStartTime.AddSeconds(Convert.ToDouble(unixTime));}
[/CODE]
Mike GoldPosted Feb 8, 2008, 6:43 PM