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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Comparision

Status
Not open for further replies.

pho01

Programmer
Mar 17, 2003
218
US
How would you do time subtraction and time comparision?
I'm looking to perform the following:

For example:
Time subtraction:
3 hours off
20060308 02:00:00.000 - 3 hours => 20060307 23:00:00.000

1 day off
20060308 02:00:00.000 - 1 day => 20060307 02:00:00.000

Time comparision:
How to compare:
20060308 02:00:00.000 > 20060302 02:00:00.000

Thanks!
 
try using Date::Manip from CPAN. The function you're looking for is most probably DateCalc.

---
cheers!
san
smoking3vc.gif


print length "The answer to life, universe & everything!
 
Or, you can write a function to convert everthing to epoc seconds, do your math, and then convert back. I do this on occassion with timelocal and localtime.

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top