PC Review


Reply
Thread Tools Rate Thread

converting Unix datetime count to .Net DateTime object

 
 
Mark Worrall
Guest
Posts: n/a
 
      4th Feb 2004
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



 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      4th Feb 2004
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      13th Feb 2004
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

"Mattias Sjögren" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help w/conversion to Unix Epoch DateTime in code Tony! Microsoft C# .NET 3 6th Apr 2009 02:40 AM
DateTime in unix format =?Utf-8?B?UGhpbGlwIFdhZ2VuYWFy?= Microsoft VB .NET 4 19th Aug 2005 09:44 PM
converting date string into datetime object Glenn M Microsoft VB .NET 1 21st Jul 2004 03:08 AM
Re: converting Unix datetime count to .Net DateTime object Mark Worrall Microsoft C# .NET 1 4th Feb 2004 08:29 AM
converting Unix datetime count to .Net DateTime object Mark Worrall Microsoft Dot NET 1 4th Feb 2004 07:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:52 PM.