Slide 13
Slide 13 text
// I want to get the last day of last month, we are the 26th May 2017
$month = date('m') - 1;
$year = date('Y');
// get the timestamp of last month
$timestampLastMonth = mktime(0, 0, 0, $month, 1, $year);
// get the last day of the month, so the 30th April
$lastDayOfTheMonth = date('t', $timestampLastMonth);
$timestampLastDayOfLastMonth = mktime(
0, 0, 0, $month, $lastDayOfTheMonth, $year
);
// I have the correct timestamp, I can call the function date
$lastDayOfLastMonth = date('Y-m-d', $timestampLastDayOfLastMonth);
echo $lastDayOfLastMonth; // 2017-04-30