Are PHP DateInterval comparable like DateTime?

前端 未结 7 2092
孤城傲影
孤城傲影 2020-12-03 13:36

I discovered that a DateTime object in PHP can be compared to another as the \">\" and \"<\" operators are overloaded.

Is it the same with DateInterval?

A

7条回答
  •  孤城傲影
    2020-12-03 13:57

    Where does $aujourdhui come from? Sure it's the same as $today linguistically, but PHP doesn't know that! Changing your code to use $today will print "oK"!

    If not defined, $aujourdhui->diff($release) will evaluate to 0 if your PHP interpreter does not abort with an error (mine does).

提交回复
热议问题