use Time::localtime; my $tm = localtime; printf "The current date is %04d-%02d-%02d\n", $tm->year+1900, ($tm->mon)+1, $tm->mday; printf "The current time is %02d:%02d:%02d\n", $tm->hour, $tm->min, $tm->sec;