Solved

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

Posted on 2011-09-07
5
332 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HttpPostedFile 1 29
Get distinct values from excel or comm seperated file 4 30
defining NULL or 0 10 44
Where is this file? 3 25
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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