Solved

convert "Number of seconds since January 1, 2008" to a date

Posted on 2011-09-07
5
308 Views
Last Modified: 2012-06-21
I'm given an integer which is the number of seconds since January 1, 2008. Is there a simple way to convert this to a date format?

Or do I have to do it the hard way (which I could, but I'd rather save myself the trouble.)
0
Comment
Question by:deleyd
5 Comments
 
LVL 22

Assisted Solution

by:p_davis
p_davis earned 50 total points
Comment Utility
DateTime dt = new DateTime(2008, 1,1,0,0,0);
DateTime newDt =  dt.AddSeconds(DateTime.Now.Subtract(dt).TotalSeconds);'

haven't tested this but was the first thought
0
 
LVL 17

Accepted Solution

by:
OriNetworks earned 225 total points
Comment Utility
DateTime myDate = new DateTime(2008,1,1,0,0,0).AddSeconds(MySeconds);
0
 
LVL 2

Assisted Solution

by:AJRDev
AJRDev earned 225 total points
Comment Utility
Almost..

Where numSeconds is your integer value:

DateTime base = new DateTime(2008, 1,1,0,0,0);
DateTime dt =  base.AddSeconds(numSeconds);'
0
 
LVL 2

Expert Comment

by:AJRDev
Comment Utility
Sorry oriNetworks.. didn't see ur post till after mine :)
0
 

Author Closing Comment

by:deleyd
Comment Utility
Wow I'm glad it's easy so I don't have to do it the hard way.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now