我正在存储从月初开始的前 12 个月的日期集合。所以我有:
my @t = localtime time();
my $m = $t[4];
my $y = $t[5];
foreach my $date (keys %$dates_ref) {
$m -= $comparison{$date}; # a hash of numbers to go back the correct number of months
$dates_ref->{$date} = mktime(0,0,0,1,$m,$y);
}
我最终得到了一堆这样的日期:本月:1356998400
即:
Tue Jan 01 2013 00:00:00 GMT+0000 (GMT Standard Time)
过去 12 个月:
1325376000 - Sun Jan 01 2012 00:00:00 GMT+0000 (GMT Standard Time)
1328054400 - Wed Feb 01 2012 00:00:00 GMT+0000 (GMT Standard Time)
1330560000 - Thu Mar 01 2012 00:00:00 GMT+0000 (GMT Standard Time)
1333238400 - Sun Apr 01 2012 01:00:00 GMT+0100 (GMT Daylight Time)
1335830400 - Tue May 01 2012 01:00:00 GMT+0100 (GMT Daylight Time)
1338508800 - Fri Jun 01 2012 01:00:00 GMT+0100 (GMT Daylight Time)
1341100800 - Sun Jul 01 2012 01:00:00 GMT+0100 (GMT Daylight Time)
1343779200 - Wed Aug 01 2012 01:00:00 GMT+0100 (GMT Daylight Time)
1346457600 - Sat Sep 01 2012 01:00:00 GMT+0100 (GMT Daylight Time)
1349049600 - Mon Oct 01 2012 01:00:00 GMT+0100 (GMT Daylight Time)
1351728000 - Thu Nov 01 2012 00:00:00 GMT+0000 (GMT Standard Time)
1354320000 - Sat Dec 01 2012 00:00:00 GMT+0000 (GMT Standard Time)
如您所见,4 月至 10 月增加了 GMT 时间。让它不这样做的最好方法是什么,所以它只是从 开始00:00
?
例如1333238400
会变成1333234800