3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Smarty plugin * ------------------------------------------------------------- * File: modifier.age.php * Type: modifier * Name: age * Purpose: Calculate the age of a string date * ------------------------------------------------------------- * @author Gabriel Heming * @param string $date Input date string * @param string $format Input date string format * @return int */ function smarty_modifier_age($date , $format = 'Y-m-d') { if(!$dateTime = DateTime::createFromFormat($format , $date)) { throw new \RuntimeException('Invalid Date format'); } return (int)($dateTime->diff(new \DateTime() , true)->format('%y')); } echo smarty_modifier_calculate_age('2000-01-01');
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function smarty_modifier_calculate_age() in /in/KpOch:26 Stack trace: #0 {main} thrown in /in/KpOch on line 26
Process exited with code 255.

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:
28.94 ms | 405 KiB | 5 Q