3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DateTimeFactory { const DATE_INTERVAL = 'PT20M'; const DATE_INTERVAL_FOR_METHOD_3 = '+20 minutes'; // I personally prefer adding DateInterval public static function createDateTimeByInterval1(DateInterval $dateInterval) { // create DateTime, add Date and/or TimeZone in constructor if needed. $dateTime = new DateTime(); return $dateTime->add($dateInterval); } // Using a ISO 8601 String public static function createDateTimeByInterval2($intervalStr) { // create DateTime, add Date and/or TimeZone in constructor if needed. $dateTime = new DateTime(); return $dateTime->add(new DateInterval($intervalStr)); } // Using modify public static function createDateTimeByInterval3($intervalStr) { // create DateTime, add Date and/or TimeZone in constructor if needed. $dateTime = new DateTime(); return $dateTime->modify($intervalStr); } } var_dump( DateTimeFactory::createDateTimeByInterval1(new DateInterval(DateTimeFactory::DATE_INTERVAL)), DateTimeFactory::createDateTimeByInterval2(DateTimeFactory::DATE_INTERVAL), DateTimeFactory::createDateTimeByInterval3(DateTimeFactory::DATE_INTERVAL_FOR_METHOD_3) );

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.0150.00416.50
8.3.50.0080.00721.21
8.3.40.0110.00718.77
8.3.30.0110.00420.20
8.3.20.0050.00320.21
8.3.10.0030.00522.04
8.3.00.0080.00022.44
8.2.180.0150.00717.13
8.2.170.0100.00322.96
8.2.160.0090.00619.07
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0000.00820.75
8.2.110.0070.00319.06
8.2.100.0070.00418.34
8.2.90.0040.00419.17
8.2.80.0060.00319.53
8.2.70.0050.00317.73
8.2.60.0040.00418.05
8.2.50.0080.00018.07
8.2.40.0040.00419.96
8.2.30.0000.00819.43
8.2.20.0000.00817.85
8.2.10.0000.00917.88
8.2.00.0040.00417.83
8.1.280.0120.00625.92
8.1.270.0090.00023.99
8.1.260.0050.00226.35
8.1.250.0080.00028.09
8.1.240.0100.00022.60
8.1.230.0030.00920.88
8.1.220.0030.00618.77
8.1.210.0000.00919.03
8.1.200.0060.00317.48
8.1.190.0040.00417.63
8.1.180.0000.00819.14
8.1.170.0040.00418.84
8.1.160.0060.00318.96
8.1.150.0000.00818.79
8.1.140.0040.00417.60
8.1.130.0030.00617.83
8.1.120.0040.00417.61
8.1.110.0050.00317.74
8.1.100.0040.00417.59
8.1.90.0030.00417.57
8.1.80.0040.00417.65
8.1.70.0040.00417.63
8.1.60.0040.00417.78
8.1.50.0020.00517.73
8.1.40.0040.00417.63
8.1.30.0020.00517.80
8.1.20.0040.00417.91
8.1.10.0000.00817.71
8.1.00.0000.00817.70
8.0.300.0000.00920.03
8.0.290.0000.00817.05
8.0.280.0040.00418.52
8.0.270.0040.00417.11
8.0.260.0030.00317.00
8.0.250.0040.00417.28
8.0.240.0000.00817.10
8.0.230.0030.00317.12
8.0.220.0000.00717.21
8.0.210.0000.00717.16
8.0.200.0000.00617.27
8.0.190.0000.00817.18
8.0.180.0000.00817.08
8.0.170.0040.00417.23
8.0.160.0000.00717.14
8.0.150.0040.00317.11
8.0.140.0040.00417.03
8.0.130.0000.00513.45
8.0.120.0000.00817.15
8.0.110.0040.00417.05
8.0.100.0070.00017.05
8.0.90.0040.00417.21
8.0.80.0060.01017.09
8.0.70.0040.00417.04
8.0.60.0080.00017.21
8.0.50.0000.00717.08
8.0.30.0110.01017.30
8.0.20.0040.01517.40
8.0.10.0000.00717.13
8.0.00.0120.00817.00
7.4.330.0000.00415.00
7.4.320.0030.00316.73
7.4.300.0000.00616.57
7.4.290.0030.00316.71
7.4.280.0030.00316.64
7.4.270.0050.00216.76
7.4.260.0030.00313.43
7.4.250.0000.00816.70
7.4.240.0070.00016.80
7.4.230.0080.00016.71
7.4.220.0060.01916.68
7.4.210.0070.00716.80
7.4.200.0000.00716.91
7.4.190.0050.00316.76
7.4.160.0130.00716.82
7.4.150.0100.01017.40
7.4.140.0090.00817.86
7.4.130.0150.00416.63
7.4.120.0080.01016.66
7.4.110.0070.01316.70
7.4.100.0120.00616.72
7.4.90.0070.01216.75
7.4.80.0150.00419.39
7.4.70.0070.01016.82
7.4.60.0140.00416.53
7.4.50.0090.00016.63
7.4.40.0130.00322.77
7.4.30.0100.00716.73
7.4.00.0040.01415.20
7.3.330.0030.00313.40
7.3.320.0030.00313.20
7.3.310.0000.00716.32
7.3.300.0040.00416.47
7.3.290.0030.01316.45
7.3.280.0100.00816.47
7.3.270.0070.01117.40
7.3.260.0070.01316.43
7.3.250.0140.00616.62
7.3.240.0150.00316.51
7.3.230.0130.00516.70
7.3.210.0100.00716.49
7.3.200.0070.01119.39
7.3.190.0070.01016.59
7.3.180.0070.01016.75
7.3.170.0140.01016.71
7.3.160.0090.00916.53
7.3.120.0110.00414.89
7.2.330.0190.00616.53
7.2.320.0040.01216.95
7.2.310.0070.01116.87
7.2.300.0130.00316.71
7.2.290.0140.00316.49
7.2.60.0000.01416.91
7.2.00.0030.01019.52
7.1.200.0150.00516.12
7.1.100.0000.01218.42
7.1.70.0000.00817.35
7.1.60.0100.01419.21
7.1.50.0030.02017.13
7.1.00.0000.05322.44
7.0.200.0080.00514.85
7.0.140.0000.07322.11
7.0.100.0200.03720.00
7.0.90.0200.04019.95
7.0.80.0170.06319.93
7.0.70.0200.04719.93
7.0.60.0200.07319.91
7.0.50.0130.06320.31
7.0.40.0030.07320.07
7.0.30.0100.06720.13
7.0.20.0100.09020.09
7.0.10.0030.04320.07
7.0.00.0130.06720.10
5.6.280.0030.07721.04
5.6.250.0070.06320.50
5.6.240.0100.07320.54
5.6.230.0170.07320.69
5.6.220.0330.05020.74
5.6.210.0130.07720.68
5.6.200.0100.04321.09
5.6.190.0100.04321.14
5.6.180.0130.04720.96
5.6.170.0130.06721.05
5.6.160.0170.07020.96
5.6.150.0100.07021.07
5.6.140.0000.06021.04
5.6.130.0130.07721.06
5.6.120.0130.08021.13
5.6.110.0030.04721.07
5.6.100.0070.04721.00
5.6.90.0070.08021.00
5.6.80.0030.04720.56
5.6.70.0070.08320.44
5.6.60.0030.04320.30
5.6.50.0170.07020.45
5.6.40.0030.08020.43
5.6.30.0070.06320.38
5.6.20.0100.05020.36
5.6.10.0030.07320.41
5.6.00.0030.07020.29
5.5.380.0030.09020.45
5.5.370.0030.06320.41
5.5.360.0170.03720.41
5.5.350.0130.04320.43
5.5.340.0070.04720.84
5.5.330.0170.07320.90
5.5.320.0100.07720.84
5.5.310.0030.08320.89
5.5.300.0070.08020.90
5.5.290.0230.06320.88
5.5.280.0000.06320.77
5.5.270.0100.05720.83
5.5.260.0100.08320.76
5.5.250.0100.08720.72
5.5.240.0100.07320.24
5.5.230.0030.06320.21
5.5.220.0170.03720.20
5.5.210.0130.06320.21
5.5.200.0070.08320.20
5.5.190.0130.04020.29
5.5.180.0070.08020.25
5.5.160.0100.07320.27
5.5.150.0100.04320.18
5.5.140.0070.08020.00
5.5.130.0070.07020.24
5.5.120.0000.05020.09
5.5.110.0100.03720.23
5.5.100.0070.07020.11
5.5.90.0030.08319.96
5.5.80.0100.06320.17
5.5.70.0030.06320.01
5.5.60.0030.06320.09
5.5.50.0070.07720.07
5.5.40.0130.04020.01
5.5.30.0130.05719.93
5.5.20.0070.07720.09
5.5.10.0200.06020.12
5.5.00.0070.08320.11
5.4.450.0070.08319.55
5.4.440.0270.06319.55
5.4.430.0200.05319.41
5.4.420.0030.06019.36
5.4.410.0170.05719.23
5.4.400.0100.06719.13
5.4.390.0030.06019.12
5.4.380.0100.07719.04
5.4.370.0070.06318.88
5.4.360.0070.05718.94
5.4.350.0100.07719.18
5.4.340.0000.08719.20
5.4.320.0030.05719.16
5.4.310.0000.04718.88
5.4.300.0070.04319.16
5.4.290.0030.06019.18
5.4.280.0000.07019.04
5.4.270.0030.05719.02
5.4.260.0070.04719.04
5.4.250.0000.04319.22
5.4.240.0170.05018.89
5.4.230.0070.05019.06
5.4.220.0070.03718.87
5.4.210.0070.07719.02
5.4.200.0070.10318.86
5.4.190.0100.06018.83
5.4.180.0170.06719.14
5.4.170.0100.06719.15
5.4.160.0070.07319.14
5.4.150.0230.08019.16
5.4.140.0130.05316.55
5.4.130.0070.05016.49
5.4.120.0070.05016.36
5.4.110.0030.08716.52
5.4.100.0000.06316.55
5.4.90.0030.07716.41
5.4.80.0070.03716.46
5.4.70.0100.05716.50
5.4.60.0070.06016.44
5.4.50.0100.05316.36
5.4.40.0070.05716.41
5.4.30.0070.04016.32
5.4.20.0030.07316.32
5.4.10.0130.06316.39
5.4.00.0000.07715.80
5.3.290.0100.07014.63
5.3.280.0030.08014.56
5.3.270.0070.07714.71
5.3.260.0130.07014.62
5.3.250.0000.04314.60
5.3.240.0130.06014.54
5.3.230.0070.06314.59
5.3.220.0100.06014.50
5.3.210.0070.06314.52
5.3.200.0030.06014.71
5.3.190.0130.06014.64
5.3.180.0070.05314.68
5.3.170.0030.08314.57
5.3.160.0130.03714.60
5.3.150.0100.06314.56
5.3.140.0070.06714.57
5.3.130.0000.04314.69
5.3.120.0070.06714.62
5.3.110.0100.07314.54
5.3.100.0070.04014.11
5.3.90.0070.07014.00
5.3.80.0100.06713.95
5.3.70.0030.07314.13
5.3.60.0230.02313.89
5.3.50.0130.03713.97
5.3.40.0030.06714.02
5.3.30.0030.07014.02
5.3.20.0030.06713.60
5.3.10.0100.05313.72
5.3.00.0070.07013.67
5.2.170.0100.02711.16
5.2.160.0100.02711.21
5.2.150.0100.03011.22
5.2.140.0030.03311.20
5.2.130.0030.06711.13
5.2.120.0030.06711.09
5.2.110.0170.05311.23
5.2.100.0000.05711.25
5.2.90.0000.03310.97
5.2.80.0130.05310.99
5.2.70.0030.05711.17
5.2.60.0030.05311.18
5.2.50.0070.02711.05
5.2.40.0100.02710.86
5.2.30.0070.05311.04
5.2.20.0030.04711.02
5.2.10.0070.05711.01
5.2.00.0070.04710.66
5.1.60.0030.0509.85
5.1.50.0030.04710.09
5.1.40.0030.04010.07
5.1.30.0030.02710.44
5.1.20.0000.03010.37
5.1.10.0030.02310.09
5.1.00.0030.02710.13
5.0.50.0030.0378.94
5.0.40.0100.0308.94
5.0.30.0030.0478.94
5.0.20.0000.0438.94
5.0.10.0000.0478.94
5.0.00.0000.0608.94
4.4.90.0000.0208.94
4.4.80.0030.0308.94
4.4.70.0070.0308.94
4.4.60.0000.0338.94
4.4.50.0000.0308.94
4.4.40.0000.0308.94
4.4.30.0030.0338.94
4.4.20.0030.0238.94
4.4.10.0030.0378.94
4.4.00.0070.0338.94
4.3.110.0000.0278.94
4.3.100.0070.0278.94
4.3.90.0070.0308.94
4.3.80.0030.0538.94
4.3.70.0030.0208.94
4.3.60.0000.0238.94
4.3.50.0070.0138.94
4.3.40.0000.0378.94
4.3.30.0030.0208.94
4.3.20.0000.0178.94
4.3.10.0030.0138.94
4.3.00.0000.0338.94

preferences:
51.73 ms | 401 KiB | 5 Q