3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/London'); $date3 = DateTime::createFromFormat('Y-m-d H:i:s', '2019-04-01 00:00:00'); // 2019-04-01 00:00:00.0 Europe/London (+01:00) $date4 = clone $date3; $date4->modify('+5 week'); // 2019-05-06 00:00:00.0 Europe/London (+01:00) echo "So the originally modified date with 5 weeks added is:"; print_r($date4); echo "\n\n"; // positive DIFF and addition echo "1. positive DIFF and addition\n"; echo "diff is: "; $positiveDifferenceDateInterval2 = $date3->diff($date4); // interval: + 1m 4d; days 35 print_r($positiveDifferenceDateInterval2->format('%R %mm %dd')); echo "; days: {$positiveDifferenceDateInterval2->days} \n"; $positiveAddedDate = clone $date3; $positiveAddedDate->add($positiveDifferenceDateInterval2); print_r($positiveAddedDate); echo "is it equal to \$date4? "; var_dump($date4->getTimestamp() === $positiveAddedDate->getTimestamp()); echo "\n"; // negative DIFF and addition echo "2. negative DIFF and addition\n"; echo "diff is: "; $negativeDifferenceDateInterval2 = $date4->diff($date3); // interval: - 1m 5d; days 35 print_r($negativeDifferenceDateInterval2->format('%R %mm %dd')); echo "; days {$negativeDifferenceDateInterval2->days}"; $negativeAddedDate = clone $date3; // so in order to make it equal to $date4 I need to subtract a negative interval instead of adding a positive one? how crazy is that?! $negativeAddedDate->sub($negativeDifferenceDateInterval2); print_r($negativeAddedDate); echo "is it equal to \$date4? "; var_dump($date4->getTimestamp() === $negativeAddedDate->getTimestamp()); echo "\n\n"; echo 'so in order to make it equal to $date4 I need to subtract a negative interval instead of adding a positive one? how crazy is that?!';

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.70.0040.01116.49
8.3.60.0160.01018.43
8.3.50.0140.00716.40
8.3.40.0160.00619.09
8.3.30.0000.01618.97
8.3.20.0050.00321.86
8.3.10.0080.00018.90
8.3.00.0090.00019.38
8.2.190.0040.01217.10
8.2.180.0140.00716.88
8.2.170.0040.01122.96
8.2.160.0100.00720.47
8.2.150.0150.00424.18
8.2.140.0070.00424.66
8.2.130.0040.00420.47
8.2.120.0050.00326.35
8.2.110.0040.00821.12
8.2.100.0080.00418.03
8.2.90.0090.00018.16
8.2.80.0000.00818.05
8.2.70.0030.00518.05
8.2.60.0050.00318.34
8.2.50.0050.00318.10
8.2.40.0050.00519.52
8.2.30.0040.00419.48
8.2.20.0040.00418.29
8.2.10.0040.00419.46
8.2.00.0000.00718.30
8.1.280.0040.01125.92
8.1.270.0040.00420.40
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0050.00524.03
8.1.230.0090.00322.82
8.1.220.0000.00817.78
8.1.210.0040.00418.77
8.1.200.0060.00317.50
8.1.190.0030.00617.47
8.1.180.0030.00618.10
8.1.170.0060.00318.63
8.1.160.0040.00419.00
8.1.150.0070.00019.09
8.1.140.0000.00720.29
8.1.130.0040.00720.29
8.1.120.0000.00717.70
8.1.110.0000.00717.59
8.1.100.0000.00817.64
8.1.90.0040.00417.64
8.1.80.0030.00717.72
8.1.70.0070.00017.62
8.1.60.0040.00417.73
8.1.50.0050.00317.58
8.1.40.0030.00617.61
8.1.30.0040.00417.86
8.1.20.0000.00817.80
8.1.10.0040.00417.72
8.1.00.0030.00517.76
8.0.300.0040.00419.90
8.0.290.0060.00317.00
8.0.280.0060.00318.53
8.0.270.0040.00417.35
8.0.260.0030.00318.53
8.0.250.0000.00717.23
8.0.240.0030.00317.11
8.0.230.0000.00717.15
8.0.220.0030.00317.23
8.0.210.0040.00317.18
8.0.200.0030.00717.14
8.0.190.0090.00017.19
8.0.180.0040.00417.26
8.0.170.0030.00517.20
8.0.160.0000.00717.09
8.0.150.0070.00017.15
8.0.140.0040.00317.17
8.0.130.0000.00513.66
8.0.120.0000.00817.09
8.0.110.0000.00716.99
8.0.100.0070.00017.08
8.0.90.0040.00417.23
8.0.80.0080.00817.18
8.0.70.0050.00317.09
8.0.60.0050.00317.07
8.0.50.0050.00217.29
8.0.30.0230.00017.29
8.0.20.0100.01717.24
8.0.10.0070.00017.32
8.0.00.0070.01516.88
7.4.330.0000.00615.55
7.4.320.0030.00316.73
7.4.300.0030.00316.89
7.4.290.0040.00416.80
7.4.280.0000.00916.84
7.4.270.0070.00416.66
7.4.260.0060.00316.82
7.4.250.0040.00416.64
7.4.240.0040.00416.71
7.4.230.0020.00516.55
7.4.220.0040.00416.87
7.4.210.0070.01016.82
7.4.200.0030.00316.68
7.4.160.0080.00816.72
7.4.140.0080.01017.86
7.4.130.0070.01516.91
7.4.120.0060.01216.71
7.4.110.0090.00916.85
7.4.100.0120.01216.86
7.4.90.0070.01016.71
7.4.80.0070.01419.39
7.4.70.0100.00716.92
7.4.60.0060.01016.81
7.4.50.0070.01016.70
7.4.40.0050.01116.67
7.4.00.0000.01215.33
7.3.330.0030.00313.40
7.3.320.0060.00013.20
7.3.310.0070.00016.41
7.3.300.0040.00416.37
7.3.290.0070.00016.26
7.3.280.0070.01016.46
7.3.260.0110.00916.48
7.3.240.0110.00716.63
7.3.230.0060.01216.60
7.3.210.0090.00916.56
7.3.200.0070.01116.54
7.3.190.0190.00416.61
7.3.180.0100.00716.50
7.3.170.0110.00616.65
7.3.160.0130.00316.77
7.3.20.0150.00816.58
7.3.10.0030.00916.93
7.3.00.0150.00516.68
7.2.330.0070.01016.59
7.2.320.0130.00316.72
7.2.310.0170.00016.62
7.2.300.0100.00716.74
7.2.290.0090.01316.72
7.2.150.0140.00716.98
7.2.140.0080.00517.32
7.2.130.0050.00917.16
7.2.120.0170.00317.22
7.2.110.0150.00817.03
7.2.100.0090.01217.32
7.2.90.0060.00617.18
7.2.80.0130.00617.20
7.2.70.0040.01517.21
7.2.60.0110.00017.31
7.2.50.0060.01617.24
7.2.40.0040.00917.09
7.2.30.0130.00917.18
7.2.20.0080.00417.24
7.2.10.0150.00616.99
7.2.00.0120.00617.09
7.1.250.0100.01015.96

preferences:
31.46 ms | 401 KiB | 5 Q