注意:localtime獲取的年份是相對(duì)于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";
新聞熱點(diǎn)
疑難解答
圖片精選