3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Zend\Stdlib { use DateTimeZone; /** * DateTime * * An extension of the \DateTime object. */ class DateTime extends \DateTime { public function __construct($time = 'now', $timezone = null) { // workaround not required for PHP 5.3.7 or newer if(version_compare(PHP_VERSION, '5.3.7','>=')){ return parent::__construct($time, $timezone); } // Check if using relative constructs if(!stristr($time, 'last') && !stristr($time, 'first')){ return parent::__construct($time, $timezone); } // Use current time with constructor to prevent setting 'first_last_day_of' flag parent::__construct('now', $timezone); // Set the timestamp by relying on strtotime and avoiding setting the // internal 'first_last_day_of' flag of DateTime object. $this->setTimestamp( strtotime($time, $this->getTimestamp()) ); return $this; } public function modify($modify) { // Workaround not required for PHP 5.3.7 or newer if(version_compare(PHP_VERSION, '5.3.7','>=')){ return parent::modify($modify); } // Check if using relative constructs if(!stristr($modify, 'last') && !stristr($modify, 'first')){ return parent::modify($modify); } // Set the timestamp by relying on strtotime and avoiding setting the // internal 'first_last_day_of' flag of DateTime object. $parsedTimestamp = strtotime($modify, $this->getTimestamp()); if ($parsedTimestamp === false) { return false; // something went wrong parsing the date } $this->setTimestamp($parsedTimestamp); return $this; } } } $interval = new DateInterval('P1D'); $dt = new \DateTime('2012-05-05'); var_dump($dt); $dt->add($interval); var_dump($dt);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.140.0030.03716.53
5.4.130.0000.07016.47
5.4.120.0000.03716.50
5.4.110.0000.06716.40
5.4.100.0000.04316.53
5.4.90.0000.06716.44
5.4.80.0030.06716.50
5.4.70.0100.06316.55
5.4.60.0070.06316.37
5.4.50.0070.06716.35
5.4.40.0070.05016.50
5.4.30.0070.06016.39
5.4.20.0070.05716.23
5.4.10.0000.05016.26
5.4.00.0030.07015.88
5.3.240.0000.04014.68
5.3.230.0030.04314.66
5.3.220.0070.05014.55
5.3.210.0070.06714.63
5.3.200.0070.07014.63
5.3.190.0030.07714.64
5.3.180.0030.06014.64
5.3.170.0030.07714.44
5.3.160.0030.07314.69
5.3.150.0070.07314.66
5.3.140.0070.07014.59
5.3.130.0030.07314.42
5.3.120.0000.04014.66
5.3.110.0070.05714.67
5.3.100.0030.03714.01
5.3.90.0030.06014.03
5.3.80.0030.03314.09
5.3.70.0070.06713.95
5.3.60.0000.05713.87
5.3.50.0000.07314.04
5.3.40.0000.07713.87
5.3.30.0070.06714.03
5.3.20.0000.07013.64
5.3.10.0030.03313.64
5.3.00.0030.03313.70

preferences:
139.66 ms | 1394 KiB | 7 Q