示例
以下是显示其基本用法的示例代码,/ tmp目录中只有两个文件--
@weekday = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
$retval = time();
print "Return time is $retval\n";
$local_time = gmtime( $retval);
print "Local time = $local_time\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
$year = $year + 1900;
$mon += 1;
print "Formated time = $mday/$mon/$year $hour:$min:$sec $weekday[$wday]\n";
尝试一下
执行以上代码后,将产生以下结果-
Return time is 1609645834
Local time = Sun Jan 3 03:50:34 2021
Formated time = 3/1/2021 3:50:34 Sun