Comments on: Fixing strtotime -1 month https://phpreferencebook.com/tips/fixing-strtotime-1-month/ PHP Reference: Beginner to Intermediate PHP5 Wed, 07 Sep 2011 23:05:47 +0000 hourly 1 https://wordpress.org/?v=4.9.13 By: mihaita25 https://phpreferencebook.com/tips/fixing-strtotime-1-month/comment-page-1/#comment-1942 Sun, 31 Jul 2011 00:55:05 +0000 https://phpreferencebook.com/?p=325#comment-1942 Hello,
just got this problem with -1 month. i’ve used something different: date(‘Y-m’, strtotime(“-“.date(‘d’).” days”)).
In my application i only needed Year and month.

]]>
By: Mario Lurig https://phpreferencebook.com/tips/fixing-strtotime-1-month/comment-page-1/#comment-1015 Wed, 11 Nov 2009 07:36:05 +0000 https://phpreferencebook.com/?p=325#comment-1015 Yes, you can absolutely use strtotimefix(‘+1 month’) because if the problem happens at +1 month, then it will happen with -1 month as well, so the function will work the same way. You don’t want to arbitrarily choose +3 weeks, because that just won’t work in the long run.

]]>
By: Sarel https://phpreferencebook.com/tips/fixing-strtotime-1-month/comment-page-1/#comment-1014 Wed, 11 Nov 2009 07:29:01 +0000 https://phpreferencebook.com/?p=325#comment-1014 I found the same problem, where I was running this on 2009-10-31 and asking for date(‘Y-m-01’, strtotime(‘+ 1 month’)) gave me 2009-12-01. For me, because ’01’ for the day, I used ‘+ 3 weeks’ instead of ‘+ 1 month’.

]]>