3v4l.org

run code in 300+ PHP versions simultaneously
<?php // example to show the magic date 1937-07-01 change in the NL // the Zend\Validate\DateStep does not account for this difference class Blar_DateTime extends DateTime { /** * Return Date in ISO8601 format * * @return String */ public function __toString() { return $this->format('Y-m-d H:i:s'); } /** * Return difference between $this and $now * * @param Datetime|String $now * @return DateInterval */ public function diff($now = 'NOW', $absolute = NULL) { if(!($now instanceOf DateTime)) { $now = new DateTime($now); } return parent::diff($now); } /** * Return Age in Years * * @param Datetime|String $now * @return Integer */ public function getAge($now = 'NOW') { return $this->diff($now)->format('%y'); } } $birthday = new Blar_DateTime('1879-03-14', new DateTimeZone("Europe/Amsterdam")); echo $birthday . "\n"; echo '<p>In the Netherlands Albert Einstein would now be ', $birthday->diff(new DateTime('NOW', new DateTimeZone("Europe/Amsterdam")))->format('%y Years, %m Months, %d Days, %h Hours, %i Minutes, %s Seconds'), ' old.</p>'; $birthday = new Blar_DateTime('1879-03-14', new DateTimeZone("Europe/London")); echo $birthday . "\n"; echo '<p>In the United Kingdom Albert Einstein would now be ', $birthday->diff(new DateTime('NOW', new DateTimeZone("Europe/London")))->format('%y Years, %m Months, %d Days, %h Hours, %i Minutes, %s Seconds'), ' old.</p>'; $birthday = new Blar_DateTime('1950-03-14', new DateTimeZone("Europe/Amsterdam")); echo $birthday . "\n"; echo '<p>the Netherlands mr. Anonymous would now be ', $birthday->diff(new DateTime('NOW', new DateTimeZone("Europe/Amsterdam")))->format('%y Years, %m Months, %d Days, %h Hours, %i Minutes, %s Seconds'), ' old.</p>'; $birthday = new Blar_DateTime('1950-03-14', new DateTimeZone("Europe/London")); echo $birthday . "\n"; echo '<p>In the mr. Anonymous would now be ', $birthday->diff(new DateTime('NOW', new DateTimeZone("Europe/London")))->format('%y Years, %m Months, %d Days, %h Hours, %i Minutes, %s Seconds'), ' old.</p>'; // output /* 1879-03-14 00:00:00 In the Netherlands Albert Einstein would now be 134 Years, 5 Months, 14 Days, 17 Hours, 54 Minutes, 49 Seconds old. 1879-03-14 00:00:00 In the United Kingdom Albert Einstein would now be 134 Years, 5 Months, 14 Days, 16 Hours, 55 Minutes, 17 Seconds old. 1950-03-14 00:00:00 the Netherlands mr. Anonymous would now be 63 Years, 5 Months, 14 Days, 17 Hours, 55 Minutes, 17 Seconds old. 1950-03-14 00:00:00 In the mr. Anonymous would now be 63 Years, 5 Months, 14 Days, 16 Hours, 55 Minutes, 17 Seconds old. now note the difference in seconds between example 1 and 2 of 28 seconds... exactly the time that does not exists in the netherlands on 1937-07-01 I conclude PHP does it correctly and Zend\Validate\DateStep should account for this. */
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Blar_DateTime::diff($now = 'NOW', $absolute = null) should either be compatible with DateTime::diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/Hk3MP on line 24 1879-03-14 00:00:00 <p>In the Netherlands Albert Einstein would now be 134 Years, 6 Months, 13 Days, 19 Hours, 14 Minutes, 43 Seconds old.</p>1879-03-14 00:00:00 <p>In the United Kingdom Albert Einstein would now be 134 Years, 6 Months, 13 Days, 18 Hours, 14 Minutes, 43 Seconds old.</p>1950-03-14 00:00:00 <p>the Netherlands mr. Anonymous would now be 63 Years, 6 Months, 13 Days, 19 Hours, 14 Minutes, 43 Seconds old.</p>1950-03-14 00:00:00 <p>In the mr. Anonymous would now be 63 Years, 6 Months, 13 Days, 18 Hours, 14 Minutes, 43 Seconds old.</p>

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:
67.97 ms | 403 KiB | 8 Q