411 REFERENCE · Wikibooks
Perl Programming/Keywords/gmtime
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Perl glob goto Keywords
The gmtime keyword
gmtime works similar to localtime, except that the returned values are localized for the standard Greenwich Time Zone. If EXPRESSION has been omitted, content of $_ is used instead. When called in list context, the last value returned by gmtime ($isdst: is daylight saving time) is always 0, as there is no daylight saving time for GMT.
Syntax
gmtime EXPRESSION
gmtime
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";
($s, $min, $h, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(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 16:15:30
0 47. day of the year, 2. day of the week
2015-Feb-17 15:15:30
Note that daylight saving time is not present in February.
See also
localtime
time
Perl glob goto Keywords