php strtotime Gets or pit next month on month

Often encountered with strtotime ( 'last month') or in the usual strtotime business logic ( '- 1 month') obtaining the month,

strtotime ( 'next month') or strtotime ( '+ 1 month') Get next month

But in the end, if the number of days before and after two months of not as much to get on with strtotime January when he can not get the desired value

For example: On October 31, last month acquired is wrong (the result of 10 months)

Also: On October 31, get next month is wrong (the result of December)

In the beginning there is the same problem with strtotime

When seeking on or next month, you can use mktime (0, 0, 0, date ( 'm') - 1, date ( 'd'), date ( 'Y'))

或mktime(0, 0, 0,date('m')+1, date('d'), date('Y'))

Guess you like

Origin www.cnblogs.com/pk-tiger/p/11773267.html