3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param DateTime $dateTime The dateTime to be rounded * * @return DateTime The rounded DateTime */ function roundDateTime(\DateTime $dateTime) { $rounded = clone $dateTime; //Avoid side effects return $rounded->setTimestamp($rounded->getTimestamp() - $rounded->getTimestamp() % 1800); return $rounded; } // Test code below $start = new \DateTime(); $end = new \DateTime('+ 1 hour'); $interval = new \DateInterval('PT1M'); $period = new \DatePeriod($start, $interval, $end); foreach($period as $minute){ echo $minute->format('Y-m-d H:i') . "\n"; echo roundDateTime($minute)->format('Y-m-d H:i') . "\n\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
2014-05-17 21:02 2014-05-17 21:00 2014-05-17 21:03 2014-05-17 21:00 2014-05-17 21:04 2014-05-17 21:00 2014-05-17 21:05 2014-05-17 21:00 2014-05-17 21:06 2014-05-17 21:00 2014-05-17 21:07 2014-05-17 21:00 2014-05-17 21:08 2014-05-17 21:00 2014-05-17 21:09 2014-05-17 21:00 2014-05-17 21:10 2014-05-17 21:00 2014-05-17 21:11 2014-05-17 21:00 2014-05-17 21:12 2014-05-17 21:00 2014-05-17 21:13 2014-05-17 21:00 2014-05-17 21:14 2014-05-17 21:00 2014-05-17 21:15 2014-05-17 21:00 2014-05-17 21:16 2014-05-17 21:00 2014-05-17 21:17 2014-05-17 21:00 2014-05-17 21:18 2014-05-17 21:00 2014-05-17 21:19 2014-05-17 21:00 2014-05-17 21:20 2014-05-17 21:00 2014-05-17 21:21 2014-05-17 21:00 2014-05-17 21:22 2014-05-17 21:00 2014-05-17 21:23 2014-05-17 21:00 2014-05-17 21:24 2014-05-17 21:00 2014-05-17 21:25 2014-05-17 21:00 2014-05-17 21:26 2014-05-17 21:00 2014-05-17 21:27 2014-05-17 21:00 2014-05-17 21:28 2014-05-17 21:00 2014-05-17 21:29 2014-05-17 21:00 2014-05-17 21:30 2014-05-17 21:30 2014-05-17 21:31 2014-05-17 21:30 2014-05-17 21:32 2014-05-17 21:30 2014-05-17 21:33 2014-05-17 21:30 2014-05-17 21:34 2014-05-17 21:30 2014-05-17 21:35 2014-05-17 21:30 2014-05-17 21:36 2014-05-17 21:30 2014-05-17 21:37 2014-05-17 21:30 2014-05-17 21:38 2014-05-17 21:30 2014-05-17 21:39 2014-05-17 21:30 2014-05-17 21:40 2014-05-17 21:30 2014-05-17 21:41 2014-05-17 21:30 2014-05-17 21:42 2014-05-17 21:30 2014-05-17 21:43 2014-05-17 21:30 2014-05-17 21:44 2014-05-17 21:30 2014-05-17 21:45 2014-05-17 21:30 2014-05-17 21:46 2014-05-17 21:30 2014-05-17 21:47 2014-05-17 21:30 2014-05-17 21:48 2014-05-17 21:30 2014-05-17 21:49 2014-05-17 21:30 2014-05-17 21:50 2014-05-17 21:30 2014-05-17 21:51 2014-05-17 21:30 2014-05-17 21:52 2014-05-17 21:30 2014-05-17 21:53 2014-05-17 21:30 2014-05-17 21:54 2014-05-17 21:30 2014-05-17 21:55 2014-05-17 21:30 2014-05-17 21:56 2014-05-17 21:30 2014-05-17 21:57 2014-05-17 21:30 2014-05-17 21:58 2014-05-17 21:30 2014-05-17 21:59 2014-05-17 21:30 2014-05-17 22:00 2014-05-17 22:00 2014-05-17 22:01 2014-05-17 22:00

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.24 ms | 409 KiB | 8 Q