perl中如何将数值转换成日期
2 回答
饮歌长啸
TA贡献1951条经验 获得超3个赞
#!/usr/bin/perl
use strict;
use Date::Calc qw(Date_to_Time Time_to_Date Add_Delta_Days);
my $dt='20140225';
my $y=substr($dt, 0, 4);
my $m=substr($dt,4,2);
my $d=substr($dt,6,2);
print "今天是 $dt\n";
my ($y1, $m1, $d1) = Add_Delta_Days($y + 0, $m + 0, $d + 0,-1);
print "昨天是 ", $y1 * 10000 + $m1 * 100 + $d1 , "\n";
my ($y2, $m2, $d2) = Add_Delta_Days($y + 0, $m + 0, $d + 0, 1);
print "明天是 " , $y2 * 10000 + $m2 * 100 + $d2 , "\n"。
- 2 回答
- 0 关注
- 733 浏览
添加回答
举报
0/150
提交
取消