我正在编写一个 perl 脚本来为日期添加天数并显示新日期:
use Time::ParseDate;
use Time::CTime;
my $date = "02/01/2003";
my $numdays = 30;
my $time = parsedate($date);
# add $numdays worth of seconds
my $newtime = $time + ($numdays * 24 * 60 * 60);
my $newdate = strftime("%m/%d/%Y",localtime($newtime));
print "$newdate\n";
The output will be:
03/03/2003
现在如何将日期字段的输入设置为 yyyymmdd 例如:my $date = "20030102"
输出也需要是:20030303
谢谢