遇到一个问题,即2个Carbon对象的字面比较不相等,并且我不确定为什么,我在下面发布了我的修补匠会议以显示问题;
>>> $t = Carbon\Carbon::today()
=> Carbon\Carbon @1548025200 {#3026
date: 2019-01-21 00:00:00.0 Europe/Berlin (+01:00),
}
>>> $f = Carbon\Carbon::parse('21-01-2019 10:02:01')->startOfDay()
=> Carbon\Carbon @1548025200 {#3035
date: 2019-01-21 00:00:00.0 Europe/Berlin (+01:00),
}
>>> $f === $t
=> false
>>> $f == $t
=> true
>>> echo $t
2019-01-21 00:00:00⏎
>>> echo $f
2019-01-21 00:00:00⏎
>>>
只是想知道为什么$f === $t
是错误的,
感谢任何可以提供帮助的人!
即使对两者都使用today()
也会返回false; (但是,如果其中任何一种都有不同的解决方案,则第一个示例更适用于我的问题)
>>> $t = Carbon\Carbon::today()
=> Carbon\Carbon @1548025200 {#3033
date: 2019-01-21 00:00:00.0 Europe/Berlin (+01:00),
}
>>> $f = Carbon\Carbon::today()
=> Carbon\Carbon @1548025200 {#3038
date: 2019-01-21 00:00:00.0 Europe/Berlin (+01:00),
}
>>> $f === $t
=> false
>>> $f == $t
=> true