By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Need some time functions

P: n/a

I have inherited a project that where I need to convert time form the
DataTime format to the old form of seconds since 1/1/70. I can't locate any
functionality in the framework (2.0) that even knows about that particular
format.

Can some one point me to some code that does that. I also need to give an
arbitrary date in the future and get time in seconds from the Epoch. I am
hoping to avoid have to write the functionality if some is already out
there.

Thanks in Advance
--
Ron Harter | Tongue, Tied and Twisted
rh*****@pobox.com | Just an earth bound misfit ... I
| Pink Floyd

Aug 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You should just be able to use the DateTime class ...

in order to get a future date ... just take ..

TimeSpan t = YourDate - new DateTime(1970,1,1);
return t.TotalSeconds;

in order to get a date from seconds just use

DateTime YourDate= new DateTime(1970,1,1).AddSeconds(yourseconds);

also remember that seconds since epoch are generally stored in UTC :D

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

"Ron Harter" <rh*****@pobox.comwrote in message
news:ep**************@TK2MSFTNGP04.phx.gbl...
>
I have inherited a project that where I need to convert time form the
DataTime format to the old form of seconds since 1/1/70. I can't locate
any functionality in the framework (2.0) that even knows about that
particular format.

Can some one point me to some code that does that. I also need to give an
arbitrary date in the future and get time in seconds from the Epoch. I am
hoping to avoid have to write the functionality if some is already out
there.

Thanks in Advance
--
Ron Harter | Tongue, Tied and Twisted
rh*****@pobox.com | Just an earth bound misfit ... I
| Pink Floyd

Aug 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.