I almost have it completed using:
The only problem with this code is I don't get the leading 0 if the day or month is less than 10. For example, today is the 8th of January. This would post 1.08.04 instead of 01.01.04.my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); ++$mon; my $newyear = $year - 100; $newyear = "0$newyear"; my $todaysdate = join(".", $mday, $mon, $year); print "Today's date is: $todaysdate";
Along with that, here's the tough part. I am trying to make an auto-delete with this script for my guestbook so really old messages get deleted when the script is run. Can someone show me how I would compare a date string like 01.08.04 with a different $time?
Ie.: Let's say I wanted to test to see if the date is older than 20 days older than today's date (meaning 20 days ago)
I have an idea on how to go about this using substrings and compare to see if the day is older, but I can't figure out how you would compare a whole string in this format to check for year month AND day. I really only need to calculate how many days ago it was and if it is greater than $autodelete="70" or so, it'll delete.
My question is, how could you do that because if today is the first of January, my method would error the script out trying to subract 70 from 01.
Any ideas on how to get the localtime into this format and check to see if it's too old would be very much appreciated. I made a start, but I think I've bitten off more than I can chew at this point.
Thanks everyone
In reply to Calculating between times by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |