<?php
$lastDate = '1452609936';
$interval = 'P0Y0M1D';
//create objects from strings
$interval = new \DateInterval($interval);
echo 'Interval: '.$interval->format('%y years, %m months, %d days')."\n";
//last sent
$lastJob = new \Datetime();
$lastJob->setTimestamp($lastDate);
//las sent + interval
$nextJob = new \Datetime();
$nextJob->setTimestamp($lastDate);
$nextJob->add($interval);
//now
$currentJob = new \Datetime();
echo 'Last Sent: '.$lastJob->format('Y/m/d').
' | Next Job: '.$nextJob->format('Y/m/d').
' | Today: '.$currentJob->format('Y/m/d')."\n";
if ($nextJob > $currentJob) {
echo 'not ready to send.';
} else {
echo 'ready to send';
}
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Interval: 0 years, 0 months, 1 days
Last Sent: 2016/01/12 | Next Job: 2016/01/13 | Today: 2016/01/13
ready to send
preferences:
206.8 ms | 404 KiB | 322 Q