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 = $now->diff($entrydatetime); // DateInterval if ($age->y > 0) { echo $age->y == 1 ? '1 year ago' : ($age->y . ' years ago'); } else if ($age->m > 0) { echo $age->m == 1 ? '1 month ago' : ($age->m . ' months ago'); } else if ($age->days > 0) { echo $age->days == 1 ? '1 day ago' : ($age->days . ' days ago'); } else { echo $age->format('%h hours, %i minutes ago'); }
Output for git.master, git.master_jit, rfc.property-hooks
129892seconds 1 day 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:
37.82 ms | 401 KiB | 8 Q