PDA

View Full Version : Noobie ? - Date Comparison


jm0285
09-23-2003, 01:27 PM
Hi all!

Sorry for such an elementary question but I am looking for a way in perl that will check the system time to see if a specific date ($enddate) has passed and return an option for yes and no. The overlap into the next year may be as long as 6 months.
Any help would be greatly appreciated!

Thanks in advance!
Jim

jm0285
09-24-2003, 12:06 PM
Figured it out......

I added this to format the date:

# Adjust system date format for comparison
# Adjusts the (0-11) format of month to (1-12)
$mon = $mon + 1;

# Adds a 0 before any months that are less than 10
if ($mon < "10"){
$mon = 0 . $mon;

# Converts to yyyymmdd format
$date1 = $year . $mon . $mday;
}
else{
$date1 = $year . $mon . $mday;
}

And this to compare an ending date from my user database

# Converts secondary date to yyyymmdd format
$date2 = $endyear . $endmonth . $endday;

# compare current system date to end date, else expired message
if ($date1 <= $date2){
}
else {
}