如何从PHP的DateTime :: diff获取累积的日子? [英] How to get aggregate days from PHP's DateTime::diff?
问题描述
$now = new DateTime('now');
$tomorrow = new DateTime('tomorrow');
$next_year = new DateTime('+1 year');
echo "<pre>";
print_r($now->diff($tomorrow));
print_r($now->diff($next_year));
echo "</pre>";
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 10
[i] => 17
[s] => 14
[invert] => 0
[days] => 6015
)
DateInterval Object
(
[y] => 1
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] => 6015
)
'显示6015?为什么不显示总天数? 1年差异对我来说意味着什么,因为几个月有不同的天数。
any ideas why 'days' shows 6015? why won't it show the total number of days? 1 year difference means nothing to me, since months have varying number of days.
推荐答案
更合适的错误报告将是#51184 ,其重点是Windows报告6015天的问题(非Windows显示OK)。
A more appropriate bug report to follow would be #51184 which focuses on the problem of Windows reporting 6015 days (non-Windows appears OK).
至于是否对#49778(涉及不同的问题)的修正会影响到这个问题还是问题仍然存在,还没有给出任何反馈。如果任何人在这里可以看看并提供一些反馈意见,那将是非常好的。
No feedback has been given as yet with regards to whether the fix for #49778 (which deals with a different issue) affects this or if the problem persists. If anyone here could take a look and provide some feedback, that would be very kind of you.
这篇关于如何从PHP的DateTime :: diff获取累积的日子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!