< Perl Programming < Keywords
![](../../../I/Crystal_Clear_action_apply.png.webp)
The code
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
![](../../../I/Crystal_Clear_action_apply.png.webp)
($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 | localtime | time | times | utime |
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.