PHP Last day of Month

///PHP Last day of Month

PHP Last day of Month

Need to get the last day of any given month? Everyone occasionally does, here’s how.\r\nExample:\r\n\r\n02-2012 = \r\n\r\n = \r\n\r\n
\r\nfunction lastday($month = '', $year = '')\r\n{\r\n	if(empty($month))\r\n    {\r\n    	$month = date('m');\r\n    }\r\n    if(empty($year))\r\n    {\r\n    	$year = date('Y');\r\n    }\r\n    $result = strtotime("{$year}-{$month}-01");\r\n    $result = strtotime('-1 second', strtotime('+1 month', $result));\r\n    return date('Y-m-d', $result);\r\n}\r\necho lastday(05, 2009);\r\n
By |2014-01-05T10:24:38+00:00March 8th, 2012|Code, PHP|0 Comments

About the Author:

Not much to know about me, I'm a 35+ year old coder, geek, gamer..

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: