perl獲取日期與時間的實例代碼
更新時間:2013年02月09日 23:29:32 作者:
perl獲取日期與時間的例子,供大家學習參考
注意:localtime獲取的年份是相對于1900的偏移,需要加上1900,而localtime獲取的month范圍是0-11,需要加1。
復制代碼 代碼如下:
#!/usr/bin/perl
my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst) = localtime();
$year += 1900;
$mon++;
my $date = "$year-$mon-$day";
print $date, "\n";
相關文章
Perl中使用File::Lockfile確保腳本單實例運行
這篇文章主要介紹了Perl中使用File::Lockfile確保腳本單實例運行的方法,本文直接給出實例,方法非常簡單,需要的朋友可以參考下2014-11-11