3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Query timestamp of entry //returns like this $entrydatetime = "2013-11-20 17:36:18"; //get current time $now = new \DateTime(); // Use DateTime on $entrydatetime $entrydatetime = new \DateTime($entrydatetime); // Seconds echo $now->getTimestamp() - $entrydatetime->getTimestamp() . "seconds\n"; // Human readable is more complex $age = $entrydatetime->diff($now); // DateInterval if ($age->years > 0) { echo $age->format('%y years ago'); } else if ($age->months > 0) { echo $age->format('%m months ago'); } else if ($age->days > 0) { echo $age->format('%a days ago'); } else { echo $age->format('%h hours, %i minutes ago'); }
Output for git.master, git.master_jit, rfc.property-hooks
129573seconds Warning: Undefined property: DateInterval::$years in /in/MZfec on line 24 Warning: Undefined property: DateInterval::$months in /in/MZfec on line 26 1 days ago

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