There's more than one way to do things | |
PerlMonks |
Re: Checking if a given date falls between 2 other specific datesby johngg (Canon) |
on Apr 20, 2006 at 08:53 UTC ( [id://544550]=note: print w/replies, xml ) | Need Help?? |
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
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
In Section
Seekers of Perl Wisdom
|
|