3v4l.org

run code in 300+ PHP versions simultaneously
<?php $now = (new DateTime())->setTime(0,0,31)->getTimestamp(); $ts = strftime('%Y-%m-%d %H:%M:00', $now); $exists = ['jobname/' . $ts => true ]; $timeAhead = 15 * 60 + $now; $jobName = 'jobname'; for ($time = $now + 30; $time < $timeAhead; $time += 60) { $ts = strftime('%Y-%m-%d %H:%M:00', $time); echo $ts . PHP_EOL; if (!empty($exists[$jobName.'/' . $ts])) { // already scheduled continue; } $exists[$jobName.'/' . $ts] = true; } echo count($exists);
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 3 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:01:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:02:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:03:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:04:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:05:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:06:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:07:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:08:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:09:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:10:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:11:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:12:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:13:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:14:00 Deprecated: Function strftime() is deprecated in /in/TD6m7 on line 12 2015-12-16 00:15:00 16
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 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
2015-12-16 00:01:00 2015-12-16 00:02:00 2015-12-16 00:03:00 2015-12-16 00:04:00 2015-12-16 00:05:00 2015-12-16 00:06:00 2015-12-16 00:07:00 2015-12-16 00:08:00 2015-12-16 00:09:00 2015-12-16 00:10:00 2015-12-16 00:11:00 2015-12-16 00:12:00 2015-12-16 00:13:00 2015-12-16 00:14:00 2015-12-16 00:15:00 16

preferences:
248.86 ms | 403 KiB | 326 Q