PHP Code: First and Last Day of Month

As I was writing some code today, I wanted a quick way to display the end of the month Date and came across this little snippet on It’s a post from 2009, but it still does what I need it to!

function firstOfMonth() { 
return date("m/d/Y", strtotime(date('m').'/01/'.date('Y').' 00:00:00')); 
function lastOfMonth() { 
return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));

The end date function goes to the NEXT month and subtracts a day to get the last day of the current month. Quite a nice piece of code if you have time sensitive offers like we do at Unique.

Orignal post: Get the first & last day of the month with PHP