- var_dump: documentation ( source)
<?php
function getDates(DateTime $date) {
if ($date->format('d') == 20) {
$nextMonth = clone $date;
$nextMonth->modify('-1 day');
$nextMonth->modify('+1 month');
return [
'start' => $date,
'end' => $nextMonth,
];
} else if ($date->format('d') == 19) {
$lastMonth = clone $date;
$lastMonth->modify('+1 day');
$lastMonth->modify('-1 month');
return [
'start' => $lastMonth,
'end' => $date,
];
}
}
$date = new DateTime('2017-09-20');
var_dump(getDates($date));
$date = new DateTime('2017-09-19');
var_dump(getDates($date));