Quantcast
Channel: Greg McMullen » code
Viewing all articles
Browse latest Browse all 3

PHP Code: First and Last Day of Month

$
0
0

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 Justin-Cook.com. 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


Viewing all articles
Browse latest Browse all 3

Trending Articles