|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-10-31 14:48 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2019-10-31 14:48 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 17:00:02 2025 UTC |
Description: ------------ When I run date('m', '-1 month'), I expect to get the number of the previous month, but it is not what always happen. Today is 2019-10-31, and when I run it I got '10'. To understand better what is happening, I tried to run date('Y-m-d', '-1 month') and I got '2019-10-01'. I believe it is because there is no day 2019-09-31, so it rounds up. But IMO it should round down in this case. Test script: --------------- $lastMonth = date('m', '-1 month'); echo $lastMonth; Expected result: ---------------- '9' Actual result: -------------- '10'