Solved

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

Posted on 2011-09-07
5
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Assisted Solution

by:p_davis
p_davis earned 50 total points
ID: 36498917
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
ID: 36499141
DateTime myDate = new DateTime(2008,1,1,0,0,0).AddSeconds(MySeconds);
0
 
LVL 2

Assisted Solution

by:AJRDev
AJRDev earned 225 total points
ID: 36499216
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
ID: 36499223
Sorry oriNetworks.. didn't see ur post till after mine :)
0
 

Author Closing Comment

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

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 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