Send a link

localtime

Table of contents



Online doc at http://www.perl.com/doc/manual/html/pod/perlfunc/localtime.html(external link)

How to use:
# $sec - Seconds after each minute (0-59)
# $min - Minutes after each hour (0-59)
# $hour - Hour since midnight (0-23)
# $monthday - Numeric day of the month (1-31)
# $month - Number of months since January (0-11)
# $year - Number of years since 1900
# $weekday - Number of days since Sunday (0-6)
# $yearday - Number of days since January 1 (0-365)
# $isdaylight - A flag for daylight savings time

my($sec, $min, $hour, $monthday, $month, $year, $weekday, $yearday, $isdaylight) = localtime(time);
$month++;
$year -= 100;
printf("%02d%02d\n", $year, $month);
$year += 2000;
printf("%04d-%02d-%02d\n", $year, $month, $monthday);

Outputting:
0510
2005-10-26