Answer the question
In order to leave comments, you need to log in
Why does the function count 0 months between February 1 and 28, and 1 month between March 1 and 31?
$datetime1 = new \DateTime(//начало месяца);
$datetime2 = new \DateTime(//конец месяца);
$interval = $datetime1->diff($datetime2);
$interval = $interval->format('%m');
Answer the question
In order to leave comments, you need to log in
For all major versions the result is the same and clumsy. Hmm...
https://3v4l.org/KXYvi
And this is what is written in the documentation:
blabalbalaaabalablala a lot of letters, yeah, here:
set date_default_timezone_set('UTC');
and everything starts to work not as before, but as it should:
https://3v4l.org/ha3O9
in the extreme example, the first two intervals within the month are zero on all versions,
and the third example from February 1 to March 1 = 1 on all versions
, and it's all connected with walking around the clock between zones (respectively, on the extreme dates, these UNCOUNTERED +-hours are zonal and, as I understand it, give a deviation from the norm)
Thanks for the interesting question.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question