You should also have a look at Date::Manip and Date::Calc. Both offer a large range of features that will probably cover your needs. Especially Date::Manip's ParseDate() function is a real time saver for tasks like this.
Example:
> perl -MDate::Manip -e 'print UnixDate(ParseDate("October 2nd"), "%Y- +% m-%d"), "\n"' 2001-10-02 > perl -MDate::Manip -e 'print UnixDate(DateCalc("October 2nd", "+ 20 +days", \$err), "%Y-%m-%d"), "\n"' 2001-10-22 > perl -MDate::Manip -e 'print UnixDate(ParseDate("today"), "%Y-%m-%d" +) , "\n"' 2001-09-28 > perl -MDate::Manip -e 'print UnixDate(ParseDate("10 days"), "%Y-%m-% +d "), "\n"' 2001-10-08 > perl -MDate::Manip -e 'print UnixDate(ParseDate("10 days ago"), "%Y- +% m-%d"), "\n"' 2001-09-18 > perl -MDate::Manip -e 'print UnixDate(ParseDate("Monday 1 week ago") +, "%Y-%m-%d"), "\n"' 2001-09-17
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com
In reply to Re: Add A Number of Days to Today's Date
by clemburg
in thread Add A Number of Days to Today's Date
by rline
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |