3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This file is part of the Nette Framework (http://nette.org) * Copyright (c) 2004 David Grudl (http://davidgrudl.com) */ namespace Nette\Utils; use Nette; if (PHP_VERSION_ID < 70000) { /** @internal */ abstract class DateTimeWorkaround extends \DateTime { public static function createFromFormat($format, $time, $timezone = NULL) { return static::_createFromFormat($format, $time, $timezone); } } } else { /** @internal */ abstract class DateTimeWorkaround extends \DateTime { public static function createFromFormat($format, $time, \DateTimeZone $timezone = NULL) { return static::_createFromFormat($format, $time, $timezone); } } } /** * DateTime. * * @author David Grudl */ class DateTime extends DateTimeWorkaround { /** minute in seconds */ const MINUTE = 60; /** hour in seconds */ const HOUR = 3600; /** day in seconds */ const DAY = 86400; /** week in seconds */ const WEEK = 604800; /** average month in seconds */ const MONTH = 2629800; /** average year in seconds */ const YEAR = 31557600; /** * DateTime object factory. * @param string|int|\DateTime * @return DateTime */ public static function from($time) { if ($time instanceof \DateTime || $time instanceof \DateTimeInterface) { return new static($time->format('Y-m-d H:i:s'), $time->getTimezone()); } elseif (is_numeric($time)) { if ($time <= self::YEAR) { $time += time(); } $tmp = new static('@' . $time); return $tmp->setTimeZone(new \DateTimeZone(date_default_timezone_get())); } else { // textual or NULL return new static($time); } } /** * @return string */ public function __toString() { return $this->format('Y-m-d H:i:s'); } /** * @param string * @return self */ public function modifyClone($modify = '') { $dolly = clone $this; return $modify ? $dolly->modify($modify) : $dolly; } /** * @param int * @return self */ public function setTimestamp($timestamp) { $zone = $this->getTimezone(); $this->__construct('@' . $timestamp); return $this->setTimeZone($zone); } /** * @return int|string */ public function getTimestamp() { $ts = $this->format('U'); return is_float($tmp = $ts * 1) ? $ts : $tmp; } /** * Returns new DateTime object formatted according to the specified format. * @param string The format the $time parameter should be in * @param string String representing the time * @param string|\DateTimeZone desired timezone (default timezone is used if NULL is passed) * @return DateTime|FALSE */ public static function _createFromFormat($format, $time, $timezone = NULL) { if ($timezone === NULL) { $timezone = new \DateTimeZone(date_default_timezone_get()); } elseif (is_string($timezone)) { $timezone = new \DateTimeZone($timezone); } elseif (!$timezone instanceof \DateTimeZone) { throw new Nette\InvalidArgumentException('Invalid timezone given'); } $date = \DateTime::createFromFormat($format, $time, $timezone); return $date ? static::from($date) : FALSE; } }

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)
8.0.110.0040.00416.86
8.0.100.0000.00716.68
8.0.90.0000.00816.93
8.0.80.0120.00916.92
8.0.70.0030.00516.71
8.0.60.0080.00016.79
8.0.50.0050.00316.71
8.0.30.0120.00816.91
8.0.20.0120.01117.40
8.0.10.0040.00416.95
8.0.00.0150.00716.74
7.4.240.0020.00516.51
7.4.230.0000.00716.61
7.4.220.0070.01116.38
7.4.210.0030.01216.59
7.4.200.0030.00316.33
7.4.160.0060.01116.50
7.4.150.0140.00517.40
7.4.140.0120.00817.86
7.4.130.0080.01016.42
7.4.120.0120.00916.55
7.4.110.0110.00616.54
7.4.100.0060.01016.38
7.4.90.0130.00616.51
7.4.80.0100.00719.39
7.4.70.0040.01416.43
7.4.60.0070.01016.45
7.4.50.0000.00816.45
7.4.40.0080.00816.31
7.4.30.0060.01316.75
7.4.00.0090.00614.81
7.3.300.0000.00716.33
7.3.290.0060.01016.28
7.3.280.0100.00916.30
7.3.270.0070.01717.40
7.3.260.0130.00416.35
7.3.250.0150.00316.45
7.3.240.0120.00616.25
7.3.230.0120.01116.48
7.3.210.0160.00316.29
7.3.200.0090.01219.39
7.3.190.0100.01016.63
7.3.180.0060.01016.75
7.3.170.0110.00516.43
7.3.160.0070.01016.20
7.2.330.0040.01316.41
7.2.320.0090.00916.50
7.2.310.0050.01516.80
7.2.300.0090.01316.54
7.2.290.0070.01016.73
7.2.60.0100.00516.39
7.2.50.0100.00316.89
7.2.00.0060.00319.32
7.1.200.0040.00815.72
7.1.70.0030.00717.16
7.1.60.0070.01719.22
7.1.50.0090.01216.90
7.1.00.0030.07722.48
7.0.200.0060.00316.49
7.0.140.0000.04021.96
7.0.110.0030.06320.06
7.0.100.0030.08020.14
7.0.90.0130.04320.10
7.0.80.0070.08319.98
7.0.70.0100.07719.92
7.0.60.0030.05319.99
7.0.50.0130.08020.32
7.0.40.0070.07020.27
7.0.30.0100.08320.23
7.0.20.0000.08320.27
7.0.10.0100.08320.14
7.0.00.0230.06320.25
5.6.280.0030.07720.95
5.6.260.0130.07020.67
5.6.250.0070.08320.71
5.6.240.0130.04320.72
5.6.230.0100.08020.71
5.6.220.0030.08320.68
5.6.210.0130.07320.61
5.6.200.0100.08020.99
5.6.190.0200.07321.05
5.6.180.0170.07721.14
5.6.170.0100.07021.11
5.6.160.0070.07721.21
5.6.150.0170.07021.18
5.6.140.0070.08321.29
5.6.130.0200.07021.11
5.6.120.0070.09021.21
5.6.110.0130.07020.97
5.6.100.0000.09020.92
5.6.90.0070.08321.22
5.6.80.0130.07320.50
5.6.70.0070.05320.67
5.6.60.0130.05020.48
5.6.50.0130.07320.50
5.6.40.0130.07720.53
5.6.30.0000.08320.35
5.6.20.0100.07320.65
5.6.10.0070.06720.32
5.6.00.0030.06720.55
5.5.380.0070.07720.44
5.5.370.0130.07320.39
5.5.360.0130.07720.49
5.5.350.0070.08320.49
5.5.340.0030.08320.97
5.5.330.0070.07720.84
5.5.320.0170.06721.02
5.5.310.0170.05721.01
5.5.300.0030.05320.81
5.5.290.0100.06720.72
5.5.280.0030.04720.77
5.5.270.0100.08020.79
5.5.260.0100.06320.70
5.5.250.0030.08320.74
5.5.240.0100.07320.19
5.5.230.0070.08020.14
5.5.220.0070.08020.30
5.5.210.0070.07720.42
5.5.200.0200.06320.35
5.5.190.0070.07720.36
5.5.180.0100.06020.27
5.5.160.0070.08320.16
5.5.150.0130.05720.41
5.5.140.0130.07720.15
5.5.130.0070.08320.28
5.5.120.0030.08020.39
5.5.110.0100.08020.21
5.5.100.0100.07320.30
5.5.90.0030.08020.10
5.5.80.0030.07020.21
5.5.70.0130.07720.22
5.5.60.0100.06720.18
5.5.50.0070.06320.21
5.5.40.0100.03320.06
5.5.30.0030.08020.09
5.5.20.0070.08320.25
5.5.10.0000.08720.16
5.5.00.0170.07020.18
5.4.450.0200.06019.28
5.4.440.0130.07319.51
5.4.430.0130.06019.41
5.4.420.0130.06719.31
5.4.410.0070.05319.50
5.4.400.0170.07019.14
5.4.390.0100.07319.01
5.4.380.0130.07019.18
5.4.370.0130.07319.31
5.4.360.0100.07319.02
5.4.350.0030.07019.01
5.4.340.0130.06319.24
5.4.320.0070.07719.14
5.4.310.0130.03719.03
5.4.300.0100.07719.18
5.4.290.0100.06318.96
5.4.280.0030.05719.33
5.4.270.0130.07018.98
5.4.260.0030.05319.33
5.4.250.0000.07319.30
5.4.240.0030.07319.00
5.4.230.0070.06019.33
5.4.220.0130.07319.16
5.4.210.0070.07718.95
5.4.200.0170.06018.98
5.4.190.0030.08018.99
5.4.180.0000.05019.30
5.4.170.0030.08319.00
5.4.160.0070.07019.22
5.4.150.0030.08018.96
5.4.140.0170.03716.59
5.4.130.0130.06016.59
5.4.120.0130.06716.56
5.4.110.0130.07016.57
5.4.100.0030.07316.45
5.4.90.0000.08016.59
5.4.80.0070.06716.63
5.4.70.0000.07316.62
5.4.60.0130.06316.52
5.4.50.0070.07716.50
5.4.40.0130.06716.58
5.4.30.0070.07716.55
5.4.20.0070.04316.25
5.4.10.0070.04016.39
5.4.00.0070.07316.00
5.3.290.0100.06014.93
5.3.280.0070.07714.49
5.3.270.0100.04314.65
5.3.260.0070.07014.64
5.3.250.0000.07314.72
5.3.240.0130.07014.60
5.3.230.0030.05314.71
5.3.220.0070.07714.63
5.3.210.0130.07014.61
5.3.200.0030.07314.68
5.3.190.0070.07314.68
5.3.180.0100.07314.73
5.3.170.0030.08014.61
5.3.160.0100.07314.68
5.3.150.0100.07014.56
5.3.140.0070.07714.59
5.3.130.0130.07014.71
5.3.120.0070.07714.66
5.3.110.0000.08014.44
5.3.100.0070.07314.09
5.3.90.0100.07014.18
5.3.80.0170.07014.08
5.3.70.0130.06714.05
5.3.60.0100.05714.11
5.3.50.0070.07713.99
5.3.40.0070.07314.00
5.3.30.0070.07013.80
5.3.20.0100.06013.85
5.3.10.0100.06713.68
5.3.00.0030.03713.69
5.2.170.0030.03712.23
5.2.160.0170.05012.23
5.2.150.0030.03712.23
5.2.140.0130.05712.23
5.2.130.0030.06312.23
5.2.120.0070.03312.23
5.2.110.0030.05712.23
5.2.100.0000.06312.23
5.2.90.0070.06012.23
5.2.80.0130.05712.23
5.2.70.0100.05712.23
5.2.60.0030.03712.23
5.2.50.0070.06312.23
5.2.40.0030.06312.23
5.2.30.0070.05712.23
5.2.20.0100.03312.23
5.2.10.0100.05312.23
5.2.00.0030.04312.23
5.1.60.0030.05012.23
5.1.50.0070.05312.23
5.1.40.0030.05012.23
5.1.30.0100.05312.23
5.1.20.0070.05312.23
5.1.10.0030.03012.23
5.1.00.0070.05012.23
5.0.50.0000.03712.23
5.0.40.0100.03312.23
5.0.30.0070.03312.23
5.0.20.0030.04312.23
5.0.10.0030.04012.23
5.0.00.0030.06312.23
4.4.90.0000.02712.23
4.4.80.0030.03312.23
4.4.70.0000.04012.23
4.4.60.0070.03312.23
4.4.50.0070.03012.23
4.4.40.0030.05012.23
4.4.30.0030.03312.23
4.4.20.0030.03312.23
4.4.10.0030.02712.23
4.4.00.0000.03012.23
4.3.110.0030.03012.23
4.3.100.0130.02312.23
4.3.90.0070.03012.23
4.3.80.0070.04712.23
4.3.70.0000.03712.23
4.3.60.0030.03012.23
4.3.50.0030.03712.23
4.3.40.0030.05012.23
4.3.30.0000.04012.23
4.3.20.0000.03712.23
4.3.10.0000.02312.23
4.3.00.0030.02712.23

preferences:
36.89 ms | 400 KiB | 5 Q