< Perl Programming < Keywords

The code
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

($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
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.