php: get next month

by prettyscripts on 2008-02-01 09:00:31

php

to get next month it should be as simple as:

PHP:

date("n"mktime(000$month 1));

according to one of the comments in mktime, an incorrect month returns if the month you’re trying to get has less number of days than the current month.

to fix, simply supply 1 in the optional day parameter:

PHP:

date("n"mktime(000$month 11));

Tags: date, mktime, month, php

No feedback yet

Leave a comment


Your email address will not be revealed on this site.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)