3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param string $from * @param string $to * @return string */ function dateDiffString($from, $to) { $fromDate = new \DateTime($from); $toDate = new \DateTime($to); if($fromDate->format('Y') !== $toDate->format('Y')){ return $fromDate->format('M d Y') . " - " . $toDate->format('M d Y'); } if($fromDate->format('m') !== $toDate->format('m')){ return $fromDate->format('M d') . ' - ' . $toDate->format('M d, Y'); } return $fromDate->format('M d') . ' - ' . $toDate->format('d, Y'); } $from = '2015-03-29'; $to = '2015-04-03'; echo dateDiffString($from, $to) . PHP_EOL; $from = '2015-03-31'; $to = '2015-04-02'; echo dateDiffString($from, $to) . PHP_EOL; $from = '2015-03-05'; $to = '2015-03-07'; echo dateDiffString($from, $to) . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Mar 29 - Apr 03, 2015 Mar 31 - Apr 02, 2015 Mar 05 - 07, 2015

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:
66.9 ms | 401 KiB | 8 Q