http://www.perlmonks.org?node_id=83821


in reply to Yesterday's or last month's date?

I have become quite happy with the Date::Manip library after reading the Perl Cookbook. I have found it slow for repetitive parsing, but it can make things very easy if you are constatly wanting odd dates using todays date as a basis.

ParseDate can take an 'english like' string and then output that date in its own format of YYYYMMDDHH:MM:SS

UnixDate is another function that converts ParseDate's output to a customisable format, similar to localtime as shown above, it lets you output things in a more customisable format if that is of any concern.

use Date::Manip qw(ParseDate UnixDate); #examples giving epoch seconds $date = ParseDate("last month"); $date = ParseDate("yesterday"); $date = ParseDate("250 days ago"); $date = ParseDate("2nd tuesday in april"); #date formating example $date = UnixDate($date, "%d-%m-%Y"); ... ...