Perl 编程/关键字/gmtime
外观
gmtime的工作方式类似于 localtime,只是返回的值是针对标准格林威治时间区本地化的。如果表达式被省略,则使用$_的内容。当在列表上下文中调用时,gmtime ($isdst返回的最后一个值(即是否为夏令时)始终为 0,因为 GMT 没有夏令时。
gmtime EXPRESSION
gmtime
该代码
($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";
在 Windows 上返回类似以下内容:
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
请注意,二月份没有夏令时。
gmtime |
localtime |
time |
times |
utime
|