?
Solved

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

Posted on 2011-09-07
5
Medium Priority
?
347 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 200 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 900 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 900 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

762 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