PHP – Compare multiple date-time’s with +60sec

  php, wordpress

Obviously I’m missing something, but can’t figure out how to compare strings which are date&time but both got in different ways.


$mod_datetime =  get_the_modified_date() .' '.get_the_modified_time();
$curr_datetime = date('Y-m-d H:i');
$plus_datetime = strtotime($mod_datetime) <= 0*0*0*60;

if( ($curr_datetime < strtotime($mod_datetime)) > $plus_datetime){ 
            echo 'True';
        } elseif ( 0*0*0*60 < (time() < strtotime($mod_datetime)) )  {
          echo 'Recently false';
        } else {
          echo 'False at all';

In wordpress to get post last modification date and time – has to use $mod_datetime which gives me return like: 2021-05-09 15:21. String $curr_datetime returns me in same format, like: 2021-05-09 15:21 (it’s all good with getting last modification date and current date.

But trouble is I’m getting wrong result in echo and obviously my if statement is in wrong way written. How to compare like:

if post has been edited 60 or less seconds ago – return true, otherwise – return false and goodbye, have a nice day.

Any thoughts appreciated.

Source: Ask PHP