3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DateTimeExtended extends DateTime { public function __get($name) { switch ($name) { case 'year': return (int)$this->format('Y'); case 'month': return (int)$this->format('n'); case 'day': return (int)$this->format('j'); case 'hour': return (int)$this->format('G'); case 'minute': return (int)$this->format('i'); case 'second': return (int)$this->format('s'); case 'dayOfWeek': return (int)$this->format('w'); case 'dayOfYear': return (int)$this->format('z'); case 'weekOfYear': return (int)$this->format('W'); case 'daysInMonth': return (int)$this->format('t'); case 'timestamp': return (int)$this->format('U'); default: throw new InvalidArgumentException(sprintf('Unknown property "%s".', $name)); } } public static function createFromFormat($format, $time, $tz = null) { if ($tz) { $date = parent::createFromFormat($format, $time, $tz); } else { $date = parent::createFromFormat($format, $time); } $errors = static::getLastErrors(); if ($errors['warning_count'] !== 0 || $errors['error_count'] !== 0) { throw new InvalidArgumentException(sprintf('Unable to parse date "%s" by pattern "%s".', $time, $format)); } if (!$date instanceof self) { return new static($date->format('Y-m-d H:i:s'), $date->getTimeZone()); } return $date; } public function format($format) { $format = preg_replace_callback('/(?:f|[Мм]есяца?|[Дд]еньнед(?:ели)?)/u', array($this, 'replaceFormatCallback'), $format); return parent::format($format); } public function replaceFormatCallback(array $matches) { switch ($matches[0]) { case 'f': return mb_strtolower(en_get_month_name($this->month)); case 'Месяц': return ru_get_month_name($this->month); case 'Месяца': return ru_get_month_name($this->month, 2); case 'месяц': return mb_strtolower(ru_get_month_name($this->month)); case 'месяца': return mb_strtolower(ru_get_month_name($this->month, 2)); case 'Деньнедели': return ru_get_weekday_name($this->dayOfWeek); case 'Деньнед': return ru_get_weekday_name($this->dayOfWeek, true); case 'деньнедели': return mb_strtolower(ru_get_weekday_name($this->dayOfWeek)); case 'деньнед': return mb_strtolower(ru_get_weekday_name($this->dayOfWeek, true)); } return $matches[0]; } public static function convert($from, $to, $value) { return static::createFromFormat($from, $value)->format($to); } public static function check($format, $value) { try { static::createFromFormat($format, $value); } catch (InvalidArgumentException $e) { return false; } return true; } }

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.3.60.0070.00718.30
8.3.50.0130.01021.14
8.3.40.0150.00018.67
8.3.30.0130.00320.17
8.3.20.0040.00418.75
8.3.10.0050.00321.00
8.3.00.0080.00022.45
8.2.180.0070.01116.50
8.2.170.0120.00622.96
8.2.160.0030.01020.52
8.2.150.0070.00724.18
8.2.140.0070.00724.66
8.2.130.0080.00026.16
8.2.120.0090.00019.64
8.2.110.0040.00720.39
8.2.100.0110.00017.59
8.2.90.0000.00919.00
8.2.80.0040.00419.39
8.2.70.0040.00817.50
8.2.60.0000.00917.80
8.2.50.0060.00318.07
8.2.40.0070.00018.03
8.2.30.0000.00719.43
8.2.20.0080.00017.58
8.2.10.0000.00717.58
8.2.00.0050.00317.70
8.1.280.0160.00925.92
8.1.270.0040.00423.99
8.1.260.0000.00726.35
8.1.250.0000.00828.09
8.1.240.0070.00323.97
8.1.230.0110.00020.89
8.1.220.0000.00818.77
8.1.210.0050.00518.84
8.1.200.0000.00917.23
8.1.190.0000.00917.53
8.1.180.0040.00418.10
8.1.170.0030.00518.51
8.1.160.0060.00318.86
8.1.150.0040.00418.57
8.1.140.0000.00717.38
8.1.130.0070.00017.78
8.1.120.0090.00017.36
8.1.110.0050.00217.38
8.1.100.0000.00717.32
8.1.90.0040.00417.39
8.1.80.0000.00717.27
8.1.70.0070.00317.39
8.1.60.0040.00417.55
8.1.50.0040.00417.46
8.1.40.0000.00917.45
8.1.30.0040.00417.51
8.1.20.0000.00817.64
8.1.10.0040.00417.42
8.1.00.0080.00017.27
8.0.300.0090.00019.89
8.0.290.0030.00617.18
8.0.280.0030.00318.30
8.0.270.0070.00017.21
8.0.260.0060.00616.74
8.0.250.0040.00416.78
8.0.240.0050.00316.78
8.0.230.0030.00316.93
8.0.220.0030.00316.75
8.0.210.0030.00316.72
8.0.200.0030.00316.93
8.0.190.0000.00716.88
8.0.180.0050.00316.70
8.0.170.0040.00416.80
8.0.160.0030.00516.90
8.0.150.0000.00816.80
8.0.140.0070.00016.84
8.0.130.0060.00013.21
8.0.120.0050.00316.68
8.0.110.0040.00416.80
8.0.100.0050.00216.69
8.0.90.0000.00816.71
8.0.80.0090.00616.81
8.0.70.0080.00016.69
8.0.60.0050.00316.86
8.0.50.0050.00316.76
8.0.30.0090.01016.86
8.0.20.0090.01017.40
8.0.10.0000.00816.99
8.0.00.0160.00416.51
7.4.330.0030.00316.74
7.4.320.0000.00616.36
7.4.300.0030.00316.50
7.4.290.0000.00716.41
7.4.280.0000.00716.53
7.4.270.0060.00016.46
7.4.260.0000.00513.32
7.4.250.0070.00016.52
7.4.240.0070.00016.52
7.4.230.0000.00716.59
7.4.220.0070.01116.43
7.4.210.0090.00916.56
7.4.200.0000.00716.36
7.4.190.0030.00516.48
7.4.160.0150.00916.52
7.4.150.0100.01317.40
7.4.140.0080.01217.86
7.4.130.0100.00716.42
7.4.120.0110.00616.38
7.4.110.0100.00716.50
7.4.100.0140.00316.36
7.4.90.0060.01116.57
7.4.80.0130.00519.39
7.4.70.0110.00816.48
7.4.60.0130.00616.46
7.4.50.0060.00316.52
7.4.40.0130.00022.77
7.4.30.0030.01416.40
7.4.00.0030.01214.76
7.3.330.0050.00013.23
7.3.320.0030.00213.14
7.3.310.0030.00316.26
7.3.300.0000.00616.18
7.3.290.0100.00316.24
7.3.280.0090.00916.15
7.3.270.0150.00317.40
7.3.260.0100.00918.24
7.3.250.0120.00516.27
7.3.240.0130.01016.16
7.3.230.0030.01316.39
7.3.210.0030.01316.55
7.3.200.0090.00919.39
7.3.190.0060.01616.13
7.3.180.0140.00316.52
7.3.170.0080.00816.27
7.3.160.0120.00416.27
7.3.120.0070.01014.56
7.3.110.0060.00914.82
7.3.100.0000.01114.74
7.3.90.0060.00614.48
7.3.80.0000.01614.80
7.3.70.0080.00414.63
7.3.60.0040.01214.70
7.3.50.0040.00814.71
7.3.40.0060.01214.72
7.3.30.0030.01014.62
7.3.20.0070.00716.50
7.3.10.0040.00416.55
7.3.00.0000.00916.53
7.2.330.0100.00716.37
7.2.320.0110.00616.52
7.2.310.0060.01616.36
7.2.300.0140.00316.70
7.2.290.0090.01216.33
7.2.250.0070.00415.03
7.2.240.0030.01515.14
7.2.230.0090.00614.59
7.2.220.0060.00315.16
7.2.210.0030.00614.91
7.2.200.0080.00814.84
7.2.190.0070.01315.12
7.2.180.0040.01114.81
7.2.170.0080.00614.80
7.2.60.0000.01616.84
7.2.00.0040.00918.99
7.1.330.0060.00615.74
7.1.320.0030.00715.52
7.1.310.0030.01015.61
7.1.300.0120.00615.50
7.1.290.0040.00715.42
7.1.280.0060.00615.62
7.1.270.0000.01715.63
7.1.260.0000.01015.55
7.1.200.0000.01615.54
7.1.100.0030.01017.97
7.1.70.0060.00316.96
7.1.60.0180.00719.24
7.1.50.0170.00716.50
7.1.00.0070.06022.54
7.0.200.0070.00316.64
7.0.140.0100.06322.00
7.0.60.0130.07720.02
7.0.50.0170.07718.04
7.0.40.0070.04720.13
7.0.30.0200.04720.20
7.0.20.0230.05020.33
7.0.10.0130.06720.07
7.0.00.0000.04320.11
5.6.280.0070.07021.11
5.6.210.0170.04320.66
5.6.200.0200.07318.18
5.6.190.0100.07720.61
5.6.180.0330.04320.39
5.6.170.0200.04020.48
5.6.160.0030.04020.51
5.6.150.0030.08018.17
5.6.140.0100.06718.21
5.6.130.0100.08318.28
5.6.120.0030.04321.03
5.6.110.0230.06021.03
5.6.100.0030.04021.03
5.6.90.0170.05321.15
5.6.80.0070.03720.43
5.6.70.0130.03320.41
5.5.350.0000.06720.34
5.5.340.0030.06317.98
5.5.330.0170.07320.27
5.5.320.0070.06020.34
5.5.310.0170.06020.37
5.5.300.0070.04018.04
5.5.290.0170.05718.04
5.5.280.0070.08320.80
5.5.270.0030.05720.71
5.5.260.0130.07320.89
5.5.250.0070.04020.72
5.5.240.0000.08020.30
5.4.450.3270.03719.18
5.4.440.3000.03319.39
5.4.430.3270.04019.19
5.4.420.3070.02719.54
5.4.410.3330.03719.36
5.4.400.3100.03719.22
5.4.390.3230.03719.09
5.4.380.3430.03719.20
5.4.370.3100.03318.87
5.4.360.3430.05018.98
5.4.350.3270.03718.98
5.4.340.3230.03719.04
5.4.320.3230.03719.22
5.4.310.3430.03719.24
5.4.300.3130.04318.98
5.4.290.3170.04019.20
5.4.280.3230.04019.05
5.4.270.3230.03718.88
5.4.260.3370.03719.23
5.4.250.3170.04019.23
5.4.240.3270.04019.23
5.4.230.3200.03719.14
5.4.220.3200.04319.08
5.4.210.3270.03718.86
5.4.200.3470.03018.97
5.4.190.3230.03719.23
5.4.180.3300.03719.13
5.4.170.3200.04019.30
5.4.160.3270.03719.11
5.4.150.3000.04318.96
5.4.140.3070.02716.52
5.4.130.3270.03016.30
5.4.120.3130.04316.34
5.4.110.3000.03716.41
5.4.100.3200.03716.46
5.4.90.3230.03316.56
5.4.80.3300.03016.29
5.4.70.3230.03316.46
5.4.60.3100.02716.61
5.4.50.2930.04016.45
5.4.40.3230.03716.48
5.4.30.2900.04016.55
5.4.20.3300.03716.55
5.4.10.3130.03716.45
5.4.00.3130.03015.80
5.3.290.3200.03714.62
5.3.280.2970.03714.64
5.3.270.3270.04014.66
5.3.260.3030.04014.81
5.3.250.2800.03714.62
5.3.240.3030.03314.77
5.3.230.3030.03314.55
5.3.220.2900.04014.59
5.3.210.2730.04014.69
5.3.200.2530.03314.66
5.3.190.3170.03314.58
5.3.180.2970.03714.52
5.3.170.2830.03314.60
5.3.160.2600.04014.73
5.3.150.2970.03714.72
5.3.140.3030.03314.62
5.3.130.2900.03714.75
5.3.120.3000.03714.56
5.3.110.2970.04014.82
5.3.100.2930.04014.20
5.3.90.2970.03714.00
5.3.80.2970.03713.97
5.3.70.2870.04014.08
5.3.60.3000.04014.06
5.3.50.3270.03713.90
5.3.40.3270.03314.14
5.3.30.3470.04013.85
5.3.20.3200.03713.64
5.3.10.3270.03713.63
5.3.00.2970.03013.69
5.2.170.2770.02713.09
5.2.160.2430.03713.09
5.2.150.2670.03313.09
5.2.140.2870.03313.09
5.2.130.2770.03013.09
5.2.120.2670.02713.09
5.2.110.2630.02713.09
5.2.100.2730.03013.09
5.2.90.2830.03313.09
5.2.80.2800.02313.09
5.2.70.2770.03013.09
5.2.60.2730.02713.09
5.2.50.2500.02713.09
5.2.40.1970.03013.09
5.2.30.2230.03013.09
5.2.20.2170.02713.09
5.2.10.1930.03013.09
5.2.00.1770.03713.09
5.1.60.2300.03013.09
5.1.50.2300.02013.09
5.1.40.2030.02013.09
5.1.30.2270.02013.09
5.1.20.2070.03013.09
5.1.10.2270.02713.09
5.1.00.2030.02313.09
5.0.50.1170.02713.09
5.0.40.1270.02013.09
5.0.30.1270.04013.09
5.0.20.1030.02013.09
5.0.10.1230.02713.09
5.0.00.1030.03313.09
4.4.90.1230.02013.09
4.4.80.1000.01313.09
4.4.70.1270.02013.09
4.4.60.1070.01313.09
4.4.50.1230.02013.09
4.4.40.1000.02313.09
4.4.30.1230.02013.09
4.4.20.1000.01713.09
4.4.10.1170.02013.09
4.4.00.1230.03013.09
4.3.110.1270.01713.09
4.3.100.1070.01313.09
4.3.90.1230.01713.09
4.3.80.1070.02013.09
4.3.70.1200.01313.09
4.3.60.1170.02013.09
4.3.50.1000.01713.09
4.3.40.1000.02313.09
4.3.30.0630.02713.09
4.3.20.0570.02013.09
4.3.10.0500.01713.09
4.3.00.0730.01713.09

preferences:
51.21 ms | 401 KiB | 5 Q