How to calculate a date a week ago from today

perl

Solution

Check `Time::Piece` and `Time::Seconds` core modules,

use Time::Piece;
use Time::Seconds;

my $t = localtime() - ONE_WEEK;
print $t->ymd;

output

2014-11-14

Problem

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: Last week is `2014-11-14`. I know we can use `Date::Calc` module, but I don't know how.

Original source