strtotime suffers from how it does its calculations:
“-1 months” on 07/31/2020 makes the date 06/31/2020, which doesn’t exist, 06/31/2020 = 07/01/2020.
the mktime line says:
Create a date object with the hour set to 0, minute set to 0, the second set to 0, the month set to the current month number -1, the day set to 1, and the year set to the current year.
PHP will wrap correctly - and say that 00/01/2020 = 12/01/2019. We don’t rely on the day number from the current date - every month has a 1st.
I’m not… 100% on how strtotime handles “first day of last month”…specifically, its order of operations.
I THINK what it does is set the day to 1, and THEN subtract a month, which will work. (7/31/2020 → 7/1/2020 → 6/1/2020)
If it does it the OTHER way around, it wont work. (7/31/2020 → 6/31/2020, which is actually 7/1/2020, and then setting the day to 1 results in 7/1/2020.)
mktime will always work, because you are hard-coding the value of the day.