localtime#
Synopsis#
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime($time);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime(); # uses current time
my $str = localtime($time); # "Thu Jan 1 00:00:00 1970"
Description#
Converts a Unix timestamp to the local time zone, returning either a 9-element list or a human-readable string depending on context.
If called without an argument (or with undef), uses the current
time. In list context, returns a 9-element list:
Index |
Field |
Range |
|---|---|---|
0 |
|
0-60 (60 = leap) |
1 |
|
0-59 |
2 |
|
0-23 |
3 |
|
1-31 |
4 |
|
0-11 (Jan = 0) |
5 |
|
years since 1900 |
6 |
|
0-6 (Sun = 0) |
7 |
|
0-365 |
8 |
|
DST flag (-1, 0, 1) |
In scalar context, returns a ctime-style string like
"Thu Jan 1 00:00:00 1970".
Uses libc::localtime_r for accurate timezone/DST handling.
See also#
gmtime, time, POSIX::strftime, POSIX::mktime