Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Date comparisons

by mikfire (Deacon)
on Feb 09, 2001 at 07:56 UTC ( [id://57333]=note: print w/replies, xml ) Need Help??


in reply to Date comparisons

I don't think anybody has mentioned this, but have you thought about using Time::Local? It is a core module ( bonus for portability ) and, to quote the manpage:
  These routines are the inverse of built-in perl fuctions
  localtime() and gmtime().  They accept a date as a six-
  element array, and return the corresponding time(2) value
  in seconds since the Epoch (Midnight, January 1, 1970).
  This value can be positive or negative.

I haven't done any bench marking, but I use these frequently to translate a human readable date ( like those found in syslogs and the like ) into seconds since the epoch. That makes it very easy to compare two dates, to calculate the delta between two dates, etc., without having to worry about month boundaries, leap years and other items that I almost always get wrong anyway.

If I have read what you are trying to do correctly, I think this module will do what you want.

mikfire

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://57333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-20 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found