411 REFERENCE · Wikibooks
Perl Programming/Keywords/localtime
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Perl local lock Keywords
The localtime keyword
localtime is a function that converts a time as returned by the time function to a nine-element list with the time analyzed for the local time zone. If used without EXPRESSION, the contents of $_ are used.
Syntax
localtime EXPRESSION
localtime
Examples
The code
($s, $min, $h, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
$year += 1900;
print $isdst . " " . $yday . ". day of the year, " . $wday . ". day of the week\n";
print $year . '-' . qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)[$mon] . '-' . $mday . ' ' . $h . ':' . $min . ':' . $s . "\n"; returns on Windows something like: 0 47. day of the year, 2. day of the week
2015-Feb-17 15:20:18
See also
gmtime
time
Perl local lock Keywords