1

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 ( ) - $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?

Xrender
  • 1,425
  • 4
  • 20
  • 25

1 Answers1

0

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.

ant1j
  • 305
  • 2
  • 18