3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('America/New_York'); $initialDate = DateTime::createFromFormat('U', '1409611999'); $initialDate = new DateTimeExtended($initialDate, new DateTimezone('UTC')); $firstDayofWeek = clone $initialDate; $lastDayofWeek = clone $initialDate; $firstDayofWeek->setDayOfWeek('Monday', DateTimeExtended::WEEK_CURRENT); $lastDayofWeek->setDayOfWeek('Sunday', DateTimeExtended::WEEK_NEXT); var_dump($firstDayofWeek, $lastDayofWeek); class DateTimeExtended Extends DateTime { const WEEK_CURRENT = 0; const WEEK_NEXT = 1; const WEEK_PREVIOUS = 2; protected static $days_of_week = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', ); public function __construct() { $args = func_get_args(); if (empty($args)) { throw new Exception('No argument supplied!'); } if ($args[0] instanceof DateTime) { parent::__construct($args[0]->format('Y-m-d H:i:s'), $args[0]->getTimezone()); } else { parent::__construct($args[0], isset($arg[1]) ? $arg[1] : null); } } public function setDayOfWeek($day, $margin = 0) { $day = strtolower($day); if (!is_int($day)) { $day = array_search($day, static::$days_of_week); } $current_day = $this->format('w'); switch($margin) { case static::WEEK_CURRENT: $interval = $day - $current_day; break; case static::WEEK_NEXT: $interval = 1; while($interval <= 7) { $current_day = ($current_day + 1) % 7; if ($current_day == $day) { break; } $interval++; } break; case static::WEEK_PREVIOUS: $interval = -1; while($interval >= -7) { $current_day -= 1; if ($current_day < 0) { $current_day = 6; } if ($current_day == $day) { break; } $interval--; } break; default: throw new Exception('Invalid margin supplied!'); } $i = abs($interval); $days = new DateInterval("P{$i}D"); if ($interval < 0) { $this->sub($days); } else { $this->add($days); } return $this; } }

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.0140.00716.75
8.3.50.0050.00922.80
8.3.40.0070.00719.09
8.3.30.0060.01319.23
8.3.20.0040.00420.30
8.3.10.0040.00423.61
8.3.00.0040.00419.51
8.2.180.0080.00818.42
8.2.170.0100.01019.07
8.2.160.0070.00722.96
8.2.150.0080.00025.66
8.2.140.0030.00624.66
8.2.130.0000.00826.16
8.2.120.0050.00321.15
8.2.110.0100.00021.04
8.2.100.0090.00317.96
8.2.90.0090.00019.34
8.2.80.0050.00317.97
8.2.70.0040.00417.75
8.2.60.0080.00018.16
8.2.50.0030.00618.10
8.2.40.0030.00520.07
8.2.30.0000.00818.13
8.2.20.0030.00518.06
8.2.10.0030.00618.27
8.2.00.0030.00518.18
8.1.280.0130.01025.92
8.1.270.0090.00023.84
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0040.00423.79
8.1.230.0060.00617.89
8.1.220.0040.00417.91
8.1.210.0050.00518.77
8.1.200.0030.00617.61
8.1.190.0040.00417.60
8.1.180.0030.00618.10
8.1.170.0030.00518.88
8.1.160.0000.00822.09
8.1.150.0030.00519.01
8.1.140.0020.00517.77
8.1.130.0000.00717.96
8.1.120.0040.00417.76
8.1.110.0000.00817.76
8.1.100.0030.00517.61
8.1.90.0000.00717.70
8.1.80.0000.00717.65
8.1.70.0050.00217.66
8.1.60.0080.00017.74
8.1.50.0060.00317.63
8.1.40.0000.00817.63
8.1.30.0060.00317.85
8.1.20.0040.00417.84
8.1.10.0040.00417.76
8.1.00.0030.00617.54
8.0.300.0000.00718.77
8.0.290.0080.00017.13
8.0.280.0040.00418.46
8.0.270.0070.00017.50
8.0.260.0000.00617.30
8.0.250.0040.00417.19
8.0.240.0000.00817.23
8.0.230.0030.00417.27
8.0.220.0000.00717.11
8.0.210.0030.00317.14
8.0.200.0070.00317.23
8.0.190.0000.00817.23
8.0.180.0100.00017.17
8.0.170.0080.00017.23
8.0.160.0000.00817.15
8.0.150.0040.00417.21
8.0.140.0070.00017.09
8.0.130.0030.00313.68
8.0.120.0040.00417.19
8.0.110.0000.00717.15
8.0.100.0000.00717.05
8.0.90.0040.00417.24
8.0.80.0100.00617.25
8.0.70.0030.00517.25
8.0.60.0040.00417.06
8.0.50.0000.00817.16
8.0.30.0100.01217.48
8.0.20.0190.00617.45
8.0.10.0040.00417.44
8.0.00.0100.00817.02
7.4.330.0020.00215.23
7.4.320.0030.00316.80
7.4.300.0000.00616.75
7.4.290.0030.00316.65
7.4.280.0060.00316.69
7.4.270.0070.00016.77
7.4.260.0050.00216.82
7.4.250.0070.00016.78
7.4.240.0020.00516.75
7.4.230.0000.00716.77
7.4.220.0150.00316.82
7.4.210.0060.01216.74
7.4.200.0040.00416.72
7.4.160.0200.01016.89
7.4.150.0140.01117.40
7.4.140.0090.00917.86
7.4.130.0080.01016.63
7.4.120.0110.00716.75
7.4.110.0150.00916.76
7.4.100.0130.00316.77
7.4.90.0100.00716.88
7.4.80.0110.00719.39
7.4.70.0030.01816.79
7.4.60.0110.00716.59
7.4.50.0030.00616.88
7.4.40.0140.00316.56
7.4.30.0070.01016.75
7.4.00.0070.01015.13
7.3.330.0000.00613.54
7.3.320.0040.00513.69
7.3.310.0000.00716.59
7.3.300.0040.00416.54
7.3.290.0100.01016.70
7.3.280.0080.01016.68
7.3.270.0070.01317.40
7.3.260.0110.00716.83
7.3.250.0080.01116.72
7.3.240.0110.00816.44
7.3.230.0100.00716.55
7.3.210.0060.01216.82
7.3.200.0000.01819.39
7.3.190.0100.00716.81
7.3.180.0100.00716.56
7.3.170.0130.00316.90
7.3.160.0090.00816.66
7.3.120.0070.01015.04
7.3.110.0060.01114.98
7.3.100.0060.01215.31
7.3.90.0100.00714.84
7.3.80.0040.01215.17
7.3.70.0040.00415.20
7.3.60.0040.00814.75
7.3.50.0050.00515.03
7.3.40.0040.01214.84
7.3.30.0100.00314.74
7.3.20.0060.00616.84
7.3.10.0040.00616.84
7.3.00.0090.00416.72
7.2.330.0130.01017.10
7.2.320.0060.01316.81
7.2.310.0070.01116.87
7.2.300.0060.01117.00
7.2.290.0120.01217.02
7.2.250.0040.01415.12
7.2.240.0000.02115.45
7.2.230.0100.00715.41
7.2.220.0030.01015.37
7.2.210.0050.00515.13
7.2.200.0090.00315.03
7.2.190.0060.00615.01
7.2.180.0000.01515.36
7.2.170.0000.01415.32
7.2.130.0040.00817.28
7.2.120.0030.01016.99
7.2.110.0070.00716.88
7.2.100.0060.00317.26
7.2.90.0000.01417.18
7.2.80.0070.00717.18
7.2.70.0060.00617.16
7.2.60.0080.00717.08
7.2.50.0000.01316.93
7.2.40.0070.00416.98
7.2.30.0060.00617.26
7.2.20.0030.00717.10
7.2.10.0040.00817.07
7.2.00.0020.01418.25
7.1.330.0060.00915.75
7.1.320.0060.00916.05
7.1.310.0000.01316.20
7.1.300.0070.01015.98
7.1.290.0060.00315.64
7.1.280.0030.00715.93
7.1.270.0030.01215.75
7.1.260.0030.00716.20
7.1.250.0090.00315.89
7.1.200.0070.00715.93
7.1.100.0030.00618.41
7.1.70.0000.00717.57
7.1.60.0090.01219.40
7.1.50.0090.01216.96
7.1.00.0000.08022.48
7.0.200.0080.00016.81
7.0.140.0070.07022.05
7.0.100.0270.07320.07
7.0.90.0300.08019.96
7.0.80.0070.08020.01
7.0.70.0100.07720.01
7.0.60.0230.08720.08
7.0.50.0100.07720.28
7.0.40.0170.03319.95
7.0.30.0030.05020.09
7.0.20.0200.07720.04
7.0.10.0130.06720.12
7.0.00.0100.06320.10
5.6.280.0000.07721.15
5.6.250.0170.04020.64
5.6.240.0130.07720.57
5.6.230.0100.04720.75
5.6.220.0100.06720.68
5.6.210.0100.04720.68
5.6.200.0000.04721.08
5.6.190.0070.07720.98
5.6.180.0030.05021.01
5.6.170.0070.04021.16
5.6.160.0130.07721.21
5.6.150.0100.06721.20
5.6.140.0130.07321.05
5.6.130.0100.07721.06
5.6.120.0030.09021.02
5.6.110.0100.03720.97
5.6.100.0000.06720.96
5.6.90.0100.07320.94
5.6.80.0100.08020.37
5.6.70.0030.06020.42
5.6.60.0170.05320.50
5.6.50.0130.07720.43
5.6.40.0030.08720.39
5.6.30.0070.04720.42
5.6.20.0130.06320.52
5.6.10.0030.08020.35
5.6.00.0030.08320.39
5.5.380.0130.07720.42
5.5.370.0070.06720.37
5.5.360.0070.05320.55
5.5.350.0070.07320.45
5.5.340.0130.04020.87
5.5.330.0170.04720.91
5.5.320.0000.08320.83
5.5.310.0070.08020.95
5.5.300.0130.07020.86
5.5.290.0100.04320.86
5.5.280.0170.07320.83
5.5.270.0070.08720.66
5.5.260.0200.04020.91
5.5.250.0030.08320.48
5.5.240.0030.08320.34
5.5.230.0130.07020.14
5.5.220.0030.08320.32
5.5.210.0100.08020.21
5.5.200.0270.06320.27
5.5.190.0170.03320.18
5.5.180.0100.03720.17
5.5.160.0100.07320.14
5.5.150.0000.04320.30
5.5.140.0170.07020.20
5.5.130.0070.04020.14
5.5.120.0030.07720.27
5.5.110.0100.05020.14
5.5.100.0070.07320.11
5.5.90.0130.06320.18
5.5.80.0070.06320.19
5.5.70.0100.07320.12
5.5.60.0130.05020.11
5.5.50.0070.06020.13
5.5.40.0100.07020.02
5.5.30.0100.06719.97
5.5.20.0070.08020.07
5.5.10.0070.07319.98
5.5.00.0100.05720.15
5.4.450.0130.08319.37
5.4.440.0070.05019.46
5.4.430.0030.05019.48
5.4.420.0030.08319.22
5.4.410.0070.07019.38
5.4.400.0030.08019.11
5.4.390.0030.04019.05
5.4.380.0100.05319.16
5.4.370.0170.06719.16
5.4.360.0130.05719.05
5.4.350.0030.04719.09
5.4.340.0100.06018.86
5.4.320.0130.07019.08
5.4.310.0000.07319.03
5.4.300.0200.04719.09
5.4.290.0100.04319.22
5.4.280.0200.06019.21
5.4.270.0030.07019.05
5.4.260.0030.08018.94
5.4.250.0130.04319.12
5.4.240.0070.04719.16
5.4.230.0200.06018.94
5.4.220.0030.07319.24
5.4.210.0000.07719.16
5.4.200.0130.04019.03
5.4.190.0100.07719.22
5.4.180.0070.07019.17
5.4.170.0070.07719.14
5.4.160.0070.06719.19
5.4.150.0170.05718.85
5.4.140.0030.04716.50
5.4.130.0030.05316.49
5.4.120.0030.05016.38
5.4.110.0030.06316.52
5.4.100.0030.06716.53
5.4.90.0100.05716.43
5.4.80.0030.06716.43
5.4.70.0030.04316.56
5.4.60.0070.07316.48
5.4.50.0030.07316.45
5.4.40.0130.06316.38
5.4.30.0000.05316.48
5.4.20.0030.04316.43
5.4.10.0100.06316.33
5.4.00.0030.03715.86
5.3.290.0130.05314.80
5.3.280.0170.06714.60
5.3.270.0070.06014.73
5.3.260.0100.04314.76
5.3.250.0070.04714.61
5.3.240.0000.04714.62
5.3.230.0070.03014.58
5.3.220.0070.04014.66
5.3.210.0030.03714.55
5.3.200.0030.06714.52
5.3.190.0070.05014.66
5.3.180.0070.07014.66
5.3.170.0030.04014.60
5.3.160.0000.03714.69
5.3.150.0100.07314.70
5.3.140.0070.06014.54
5.3.130.0070.04314.63
5.3.120.0130.06714.71
5.3.110.0070.06314.58
5.3.100.0030.08314.04
5.3.90.0070.04314.13
5.3.80.0030.04714.18
5.3.70.0070.04013.94
5.3.60.0030.05714.01
5.3.50.0100.05314.00
5.3.40.0130.06713.89
5.3.30.0030.04313.92
5.3.20.0100.05013.84
5.3.10.0030.07313.73
5.3.00.0130.07013.71
5.2.170.0030.06311.16
5.2.160.0100.05711.23
5.2.150.0070.05011.30
5.2.140.0130.05011.05
5.2.130.0130.04311.03
5.2.120.0030.04011.27
5.2.110.0130.05311.21
5.2.100.0070.05011.25
5.2.90.0100.05011.18
5.2.80.0030.06011.24
5.2.70.0070.03311.23
5.2.60.0100.03311.12
5.2.50.0130.05011.04
5.2.40.0030.06311.04
5.2.30.0030.05011.13
5.2.20.0030.06010.96
5.2.10.0030.05010.88
5.2.00.0030.06010.75
5.1.60.0100.04010.02
5.1.50.0130.04310.12
5.1.40.0100.04710.07
5.1.30.0100.05310.41
5.1.20.0030.03010.51
5.1.10.0030.06010.08
5.1.00.0070.0309.93
5.0.50.0070.0378.41
5.0.40.0030.0408.47
5.0.30.0070.0638.30
5.0.20.0030.0408.30
5.0.10.0000.0508.27
5.0.00.0070.0608.23
4.4.90.0030.0338.00
4.4.80.0000.0378.00
4.4.70.0030.0378.00
4.4.60.0030.0338.00
4.4.50.0000.0378.00
4.4.40.0030.0278.00
4.4.30.0030.0138.00
4.4.20.0000.0178.00
4.4.10.0000.0308.00
4.4.00.0000.0438.00
4.3.110.0030.0378.00
4.3.100.0030.0338.00
4.3.90.0030.0278.00
4.3.80.0030.0508.00
4.3.70.0100.0238.00
4.3.60.0100.0278.00
4.3.50.0000.0278.00
4.3.40.0070.0478.00
4.3.30.0070.0238.00
4.3.20.0030.0338.00
4.3.10.0000.0308.00
4.3.00.0000.0338.00

preferences:
69.09 ms | 400 KiB | 5 Q