#!usr/bin/perl use say; use strict; use warnings; use DateTime; my $time_now = DateTime ->now( time_zone => 'local' ); say $time_now->strftime("%Y, %m, %d"); my $one_month_ago = DateTime ->now( time_zone => 'local' ) ->subtract( days => 30 ); say $one_month_ago->strftime("%Y, %m, %d"); __END__ $ perl test.pl 2017, 06, 23 2017, 05, 24