How do I compare two DateTime objects in PHP 5.2.8?

后端 未结 7 2052
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 17:42

Having a look on the PHP documentation, the following two methods of the DateTime object would both seem to solve my problem:

  • DateTime::diff : Get
7条回答
  •  天涯浪人
    2020-11-22 17:49

    The following seems to confirm that there are comparison operators for the DateTime class:

    dev:~# php
     $d2);
    var_dump($d1 < $d2);
    ?>
    bool(false)
    bool(true)
    bool(false)
    dev:~# php -v
    PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 20:09:03)
    Copyright (c) 1997-2008 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
    dev:~#
    

提交回复
热议问题