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