I am working with php and have to compare some data created between the first of the current month and the first of the next month.
I use date('Y-m-d', strtotime('+1 month'));
to get the first of the next month. Does this mean that I get the January 1st 2019 when the current date is e.g. 2018-12-16? Or does strtotime('+1 month')
just adds the next month and ignores the year, so the result would be 2018-01-16...?
I am not sure, if this is the way strtotime('+1 month')
works and I can't test it with a hardcoded month; date('Y-12-d', strtotime('+1 month'));
returns 2018-12-28... Did I even test it in the correct way?
Thanks for your help!
strtotime('+1 month')
add the 1 month in current month, for example
if current date is 2018-06-28 then
echo date('Y-m-d', strtotime('+1 month'));
Output is :
2018-07-28
If you want first date of month then use :
echo date('Y-m-01', strtotime('+1 month')); // +1 month (Jun to July)
or
echo date('Y-m-01'); // Return Current Month
If current month is December
and you add 1 month with strtotime('+1 month')
then your date will be in next year