note 124048 rejected from dateinterval.format by cmb

From: Date: Fri, 19 Jul 2019 06:12:11 +0000
Subject: note 124048 rejected from dateinterval.format by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211619@lists.php.net to get a copy of this message
Note Submitter: dmitry dot y dot kapustin at gmail dot com ---- I'm trying to get the difference of two dates in months, but I get such a surprise (5 months instead of 19 months): $date_start = new DateTime("2018-01-01"); $date_stop = new DateTime("2019-07-18"); $interval = $date_start->diff($date_stop); echo $interval->format("%r%m"); // 5 print_r($interval); DateInterval Object ( [y] => 1 [m] => 6 [d] => 16 [h] => 0 [i] => 0 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 563 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 )

« previous php.notes (#211619) next »