time |
自纪元(00:00:00 UTC1970年1月1日),返回的秒数(对于大多数系统);1904年1月1日,00:00:00,对于Mac OS。适用于gmtime的和localtime。
整数,纪元以来的秒数
#!/usr/bin/perl -w #by www.gitbook.net @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 1176831539
Local time = Tue Apr 17 17:38:59 2007
Formated time = 17/4/2007 17:38:59 Tue