I like timelocal_nocheck for simple date addition/subtraction because it will DWYM when you ask for something like "the 0th day of October" (as we do in this example) or "the 20,000th second of January." See the POD for more info & examples.#/usr/bin/perl -l use POSIX 'strftime'; use Time::Local 'timelocal_nocheck'; my ($d, $m, $y) = (localtime)[3,4,5]; my $yesterday = timelocal_nocheck 0, 0, 0, $d - 1, $m, $y; my $fivehundred = timelocal_nocheck 0, 0, 0, $d + 500, $m, $y; print "Today: ", strftime "%Y%m%d", localtime; print "Yesterday: ", strftime "%Y%m%d", localtime $yesterday; print "In 500 days: ", strftime "%Y%m%d", localtime $fivehundred; __END__ Today: 20041001 Yesterday: 20040930 In 500 days: 20060213
Update: added ridiculous +500 days example
blokhead
In reply to Re: Date Trickiness
by blokhead
in thread Date Trickiness
by monger
For:
Use:
& & < < > > [ [ ] ]