PHP: What are these Date (diff?) format parameters (eg. %R%a)

后端 未结 2 1687
醉酒成梦
醉酒成梦 2021-01-20 03:35

I runned into few examples where people share code for calculating the difference between two days.

Eg.

$now = new DateTime();
$itemDate->diff($n         


        
2条回答
  •  春和景丽
    2021-01-20 04:16

    When doing difference between DateTimeInterface objects, DateInterval object will be returned. You don't have DateTime's anymore, you have interval, and intervals are formatted different as DateTime objects. Format is explained here: http://php.net/manual/en/dateinterval.format.php

提交回复
热议问题