3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $lastDate = '1452699936'; $interval = 'P0Y0M3D'; //create objects from strings $interval = new \DateInterval($interval); $this->message('Interval: '.$interval->format('%y years, %m months, %d days')); //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 'ready to send'; } else { echo 'not ready to send.'; }
based on eblvr
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/FsGAT:7 Stack trace: #0 {main} thrown in /in/FsGAT on line 7
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Fatal error: Using $this when not in object context in /in/FsGAT on line 7
Process exited with code 255.