PHP DateInterval missing a period

心已入冬 提交于 2020-01-16 06:09:52

问题


My aim is to generate a timestamp of every minute between two given dates (the actual problem is different, but this is similar in structure and simpler to describe). I'm using the following code:

    $Interval = DateInterval::createFromDateString('1 minute');
    $Period = new DatePeriod('2013-01-01', $Interval, '2014-01-01');

    foreach ($Period as $Dt){
       echo "Minute" . $Dt->format('i');
    }       

Problem is when I run this, I would expect to find 365*24*60 entries, or 525,600, but instead only 525,540 are returned. Interestingly, a whole 60 minute period is missing in March (13th March, 2-3am is missing).

This is really weird.. am I missing something completely obvious? Using PHP version 5.4.16

Cheers, Adrian

来源:https://stackoverflow.com/questions/17444712/php-dateinterval-missing-a-period

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!