当我使用 DateInterval 类时,它返回一个名为“d”的属性,然后返回另一个名为“Days”的属性,我真的很困惑这两者之间的区别。有人可以解释一下吗。
下面是我的代码中返回的对象的示例。
DateInterval(
y =
0
m =
1
d =
1
h =
3
i =
16
s =
6
weekday =
0
weekday_behavior =
0
first_last_day_of =
0
invert =
1
days =
31
special_type =
0
special_amount =
0
have_weekday_relative =
0
have_special_relative =
0
最佳答案
d
- 添加月份后需要添加的从月初的天数 -(Feb 23 - Jan 1).d == 22
)days
- 总天数 -(Feb 23 - Jan 1).days == 31 + 22
)
来自 the documentation :
d
Number of days.
days
If the DateInterval object was created by DateTime::diff(), then this is the total number of days between the start and end dates. Otherwise, days will be FALSE.
Before PHP 5.4.20/5.5.4 instead of FALSE you will receive -99999 upon accessing the property.
关于php - DateInterval 中的天数和 "d"属性有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30446918/