Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert ctime to DateTime in C#

Status
Not open for further replies.

shabnam

Programmer
Oct 3, 2000
26
0
0
US
I have some files written using VC++ 6, they use ctime. I need to convert the data to a datetime object in C#. ctime starts from 1 Jan 1970 while datetime in C# apparently starts from 1 Jan 1601.

As a example - the old code stores the date - 15 Sep 2003 as 1063664140 (this includes the time also) - the equivalent value for DateTime is 127081125400000000. I cannot find any appropriate convert function.

Any help will be appreciated
 
shabnam - take a look at thread732-650856 and see if it will answer your question.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Chiph - that does help somewhat - my date convert fine except for the hour - the other components - including the min and second are fine - the hour is always 7-8 + of what it should be so if the date is 01/01/2003 1:1:1 it will convert as 01/01/2003 8:1:1. Any suggestions?
 
What timezone are you in?
Remember that the Unix Epoch date is UTC/GMT.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
The timezone was the problem - thanks a ton. It is working fine now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top