use POSIX 'strftime'; my $then = time - (14 * 24 * 60 * 60); my $date = strftime ('%Y%m%d', localtime $then); print $date; # prints 20020524