I wanna calculate the date a week ago from today with a specific format and put it in to a variable. For example, today is Nov 21st. 2014
, and I wanna print out
use DateTime;
my $now = DateTime->now(time_zone => 'local')->subtract(weeks => 1);
print $now->ymd, ' ',$now->hms;
Instead of one week you can subtract 7 days using Date::Calc module
use Date::Calc qw(Add_Delta_Days);
my @date = Add_Delta_Days( 2014, 11, 21, -7 );
print join('-', @date);
OUTPUT
2014-11-14