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!

newbie question, date diff

Status
Not open for further replies.

NWNinja

IS-IT--Management
May 24, 2005
166
SE
Hi all!
I have a probably simple question. I have a string that´s parsed from a file. This string contains a time/date in the following format:
Wed Aug 16 19:05:43 2006
I need to compare that time with the system time, and find how many hours have past between them. Any suggestions?

Cheers!
Maverick
 
Sounds like homework...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
It would be much easier if you could change the format of the date to make the month a number, preferrably something like this:
Wed 7 16 19:05:43 2006.
It would help even more if the day of the year could be provided, for example:
Wed 226 19:05:43 2006, in which case days could simply be converted to hours by multiplying by 24, and years to hours by multiplying by 8760. Some things have to change with leap years etc., but with those changes it should definitely make things a lot easier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top