Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

get_next_month (See related posts)

// description of your code here

function get_next_month($date) {
	$date = str_replace("/", "-", $date); 
	$year=date("Y",strtotime($date));
	$month=date("n",strtotime($date)) + 1;
	if ($month == 13) {
		$month = 1;
		$year++;
	}
	$day = date("t", mktime(0, 0, 0, $month, 1, $year));
	return date("Y/m/d", mktime(0, 0, 0, $month, $day, $year));
}

Comments on this post

ChristophNeymeyr posts on Jan 16, 2009 at 11:54
Sorry to say but this won´t work very well. Adding 1 to month will result in 13, which you reset to 1 to get january. But in that case, you return the same year, not $year++;
sekihin posts on Jan 19, 2009 at 01:40
Thanks~

You need to create an account or log in to post comments to this site.