PHP Get first and last date of month

09:57 AM by Christian Koch

Filed under php

Last modified Thursday April 17th, 2014

Learn how to get the first and last day of a month.

$selectedDay = '2014-04-17';
$firstDay = date('Y-m-01', strtotime($selectedDay));
$lastDay = date('Y-m-t', strtotime($selectedDay));

print "First day of month: $firstDay\n";
print "Last day of month: $lastDay\n";


Related Articles

                                                          Leave a Comment