zend 日期和夏令时
我对冬季/夏季时间交叉的日期有问题。请参阅示例
$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 生成 9...我的时区是伦敦,但我认为 fix_dst 应该解决夏季问题?我也尝试过将时区设置为 GMT 和 UTC 但有相同的效果吗?有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
时间戳没有时区信息。您应该避免将它们用于此用例。
可能您应该尝试在您的2 个日期。这将处理夏令时。
另请检查您的时区,因为根据我从上面的链接中读到的内容:
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 :