3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DateTimeFactory { const DATE_INTERVAL = 'PT20M'; // 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)); } } var_dump( DateTimeFactory::createDateTimeByInterval1(new DateInterval(DateTimeFactory::DATE_INTERVAL)), DateTimeFactory::createDateTimeByInterval2(DateTimeFactory::DATE_INTERVAL), );

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.0100.01018.43
8.3.50.0250.00521.20
8.3.40.0120.00318.93
8.3.30.0030.01020.29
8.3.20.0040.00420.16
8.3.10.0000.00821.92
8.3.00.0040.00422.32
8.2.180.0100.01018.54
8.2.170.0120.00922.96
8.2.160.0090.00622.18
8.2.150.0000.00924.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0000.00820.69
8.2.110.0060.00320.50
8.2.100.0070.00417.91
8.2.90.0050.00319.05
8.2.80.0040.00417.97
8.2.70.0040.00417.61
8.2.60.0090.00017.92
8.2.50.0050.00318.07
8.2.40.0040.00420.01
8.2.30.0000.00719.41
8.2.20.0040.00417.68
8.2.10.0030.00517.84
8.2.00.0000.00717.90
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0050.00522.53
8.1.230.0040.00717.51
8.1.220.0030.00517.74
8.1.210.0060.00318.77
8.1.200.0060.00317.35
8.1.190.0040.00417.53
8.1.180.0100.00018.10
8.1.170.0080.00018.63
8.1.160.0070.00418.82
8.1.150.0070.00018.72
8.1.140.0000.00817.64
8.1.130.0040.00417.83
8.1.120.0000.00717.61
8.1.110.0040.00417.48
8.1.100.0030.00517.61
8.1.90.0040.00417.56
8.1.80.0000.00717.61
8.1.70.0000.00717.63
8.1.60.0000.00817.65
8.1.50.0050.00217.57
8.1.40.0000.00817.66
8.1.30.0040.00417.82
8.1.20.0040.00417.82
8.1.10.0000.00817.54
8.1.00.0030.00617.67
8.0.300.0040.00418.77
8.0.290.0030.00517.00
8.0.280.0030.00318.39
8.0.270.0030.00317.29
8.0.260.0000.00716.92
8.0.250.0070.00017.11
8.0.240.0080.00017.20
8.0.230.0000.00717.15
8.0.220.0030.00417.02
8.0.210.0030.00417.15
8.0.200.0000.00617.23
8.0.190.0070.00017.11
8.0.180.0050.00317.14
8.0.170.0040.00417.04
8.0.160.0000.00717.00
8.0.150.0000.00917.10
8.0.140.0050.00217.08
8.0.130.0000.00513.50
8.0.120.0000.00817.10
8.0.110.0000.00717.14
8.0.100.0000.00816.89
8.0.90.0040.00416.94
8.0.80.0090.00617.06
8.0.70.0030.00517.01
8.0.60.0040.00417.01
8.0.50.0040.00417.14
8.0.30.0100.00917.24
8.0.20.0160.00317.40
8.0.10.0040.00417.18
8.0.00.0090.01016.94
7.4.330.0030.00315.13
7.4.320.0000.00616.61
7.4.300.0070.00016.73
7.4.290.0030.00316.63
7.4.280.0000.00716.75
7.4.270.0070.00016.59
7.4.260.0000.00513.30
7.4.250.0050.00316.75
7.4.240.0020.00616.75
7.4.230.0000.00716.76
7.4.220.0060.02016.77
7.4.210.0050.01216.70
7.4.200.0000.00716.78
7.4.190.0070.00016.72
7.4.160.0100.00516.66
7.4.150.0150.00317.40
7.4.140.0070.01017.86
7.4.130.0100.01216.81
7.4.120.0100.00816.72
7.4.110.0190.00016.67
7.4.100.0070.01016.63
7.4.90.0100.00716.66
7.4.80.0090.01219.39
7.4.70.0080.00816.51
7.4.60.0140.01116.76
7.4.50.0050.00216.46
7.4.40.0070.01022.77
7.4.30.0070.01016.54
7.3.330.0000.00513.41
7.3.320.0050.00013.38
7.3.310.0030.00316.30
7.3.300.0070.00016.34
7.3.290.0100.00716.40
7.3.280.0030.01316.41
7.3.270.0100.00717.40
7.3.260.0080.01716.42
7.3.250.0120.00616.42
7.3.240.0080.00816.60
7.3.230.0090.00916.55
7.3.210.0090.00916.30
7.3.200.0000.01819.39
7.3.190.0150.00316.41
7.3.180.0130.00316.31
7.3.170.0070.01016.73
7.3.160.0090.00916.58
7.2.330.0070.01116.54
7.2.320.0130.00316.48
7.2.310.0120.00916.23
7.2.300.0080.00816.25
7.2.290.0090.01216.10
5.4.240.0160.05712.40
5.4.230.0160.05812.39
5.4.220.0160.05712.39
5.4.210.0160.03812.39
5.4.200.0190.05712.39
5.4.190.0110.04212.39
5.4.180.0160.04712.39
5.4.170.0190.05612.39
5.4.160.0140.04712.39
5.4.150.0250.07412.39
5.4.140.0290.07312.08
5.4.130.0160.04412.06
5.4.120.0260.05512.02
5.4.110.0260.07412.02
5.4.100.0160.06412.02
5.4.90.0190.06212.02
5.4.80.0260.07512.02
5.4.70.0130.04612.02
5.4.60.0190.06012.01
5.4.50.0270.07112.02
5.4.40.0300.06912.00
5.4.30.0150.04412.00
5.4.20.0190.07912.00
5.4.10.0150.04312.00
5.4.00.0270.07311.49
5.3.280.0230.05812.71
5.3.270.0200.06012.72
5.3.260.0140.04712.72
5.3.250.0290.07812.72
5.3.240.0160.04112.72
5.3.230.0120.04512.71
5.3.220.0190.05912.68
5.3.210.0220.06312.68
5.3.200.0140.04312.68
5.3.190.0130.04512.68
5.3.180.0200.05712.67
5.3.170.0240.07812.67
5.3.160.0150.04812.67
5.3.150.0230.05912.67
5.3.140.0170.06512.66
5.3.130.0190.06212.66
5.3.120.0300.06812.66
5.3.110.0280.06912.66
5.3.100.0180.06012.12
5.3.90.0560.06612.09
5.3.80.0220.06012.08
5.3.70.0240.05712.08
5.3.60.0250.06612.07
5.3.50.0240.05812.01
5.3.40.0230.05912.01
5.3.30.0610.06211.97
5.3.20.0340.06711.75
5.3.10.0160.04411.71
5.3.00.0140.04411.70

preferences:
41.24 ms | 400 KiB | 5 Q