my $date = '2005-03-29'; my $d = ...; # anyone knows of a direct way to do this? for (1, 7, 14) { my $d = $d - $_ * 60 * 60 * 24; printf ("$_ days ago: %04d-%02d-%02d",(localtime($d))[5,4,3]); }