Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Checking if a given date falls between 2 other specific dates

by johngg (Canon)
on Apr 20, 2006 at 08:53 UTC ( [id://544550]=note: print w/replies, xml ) Need Help??


in reply to Checking if a given date falls between 2 other specific dates

If your date strings are consistent and simple to break down then you would be able to use the Time::Local module which is a standard part of Perl. The localtime() function turns date values for second, minute etc. into the number of seconds elapsed since the epoch for your particular o/s. Like this

my $epochSecs = localtime($secs, $mins, $hours, $mday, $mon, $year);

Note that $mon is 0 for January to 11 for December.

Once you have converted your three dates to epoch seconds you can do a simple numeric comparison.

If, however, your date strings are complex and inconsistent then using a module as chargrill suggests would probably be less painful.

Cheers,

JohnGG

Update: tag cock-up corrected

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-24 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found