开发者

zend date and summertime

I have a issue with dates crossing from winter/summer time.. please see example

        $pickUpDate = '2011-10-23';
        $dropOffDate = '2011-10-31';
        $pickUpTime = '09:00';
        $dropOffTime = '09:00';

        Zend_Date::setOptions(array('fix_dst' => false));
        Zend_Date::setOptions(array('fix_dst' => false));
        $pickUpDateTime = new Zend_Date ( $pickUpDate);
        $pickUpDateTime->setTime ( $pickUpTime );
        $dropOffDateTime = new Zend_Date ( $dropOffDate);
        $dropOffDateTime->setTime ( $dropOffTime );


        $dateDiff = ceil(($dropOffDateTime->getTimestamp ( )开发者_如何学Go - $pickUpDateTime->getTimestamp ( )) / (3600 * 24));
        echo $dateDiff;

Echo produces 9... My Timezone is London, but I thought the fix_dst should fix the summertime issue? I have also tried to set timezone to GMT and UTC but has the same effect? any ideas?


Timestamps do not have Timezone information. You should avoid using them for this use case.

May be you should try with Zend_Date::sub method between your 2 dates. This will take care of DST.

Please also review your timezone because from what I read from the link above :

If your actual timezone within the instance of Zend_Date is set to UTC or GMT the option 'fix_dst' will not be used because these two timezones do not work with DST.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜