3v4l.org

run code in 300+ PHP versions simultaneously
<?php $initialDate = DateTimeExtended::createFromFormat('U', '1409611999'); $firstDayofWeek = clone $initialDate; $lastDayofWeek = clone $initialDate; $firstDayofWeek->setDayOfWeek('Monday', DateTimeExtended::WEEK_CURRENT); $lastDayofWeek->setDayOfWeek('Sunday', DateTimeExtended::WEEK_CURRENT); 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.0070.01116.50
8.3.50.0120.00422.84
8.3.40.0090.00618.92
8.3.30.0120.00619.21
8.3.20.0040.00420.21
8.3.10.0040.00423.48
8.3.00.0090.00019.63
8.2.180.0120.00416.50
8.2.170.0070.01022.96
8.2.160.0160.00620.58
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0040.01119.87
8.2.110.0060.00619.30
8.2.100.0080.00418.03
8.2.90.0000.00819.20
8.2.80.0080.00017.97
8.2.70.0040.00417.63
8.2.60.0030.00618.16
8.2.50.0040.00418.07
8.2.40.0080.00020.07
8.2.30.0020.00518.04
8.2.20.0050.00318.08
8.2.10.0030.00518.04
8.2.00.0080.00018.03
8.1.280.0110.01125.92
8.1.270.0080.00023.83
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0070.01121.11
8.1.230.0090.00317.51
8.1.220.0050.00317.74
8.1.210.0030.00618.77
8.1.200.0060.00317.50
8.1.190.0040.00417.48
8.1.180.0080.00018.10
8.1.170.0030.00618.71
8.1.160.0050.00321.97
8.1.150.0040.00418.97
8.1.140.0000.00817.65
8.1.130.0000.00717.91
8.1.120.0050.00317.66
8.1.110.0080.00017.61
8.1.100.0000.00717.54
8.1.90.0040.00417.65
8.1.80.0000.00717.68
8.1.70.0000.00817.47
8.1.60.0060.00317.63
8.1.50.0000.00817.61
8.1.40.0050.00317.64
8.1.30.0030.00617.66
8.1.20.0030.00517.66
8.1.10.0000.00817.56
8.1.00.0050.00317.65
8.0.300.0050.00218.77
8.0.290.0080.00016.88
8.0.280.0070.00018.54
8.0.270.0050.00217.36
8.0.260.0030.00317.37
8.0.250.0030.00317.26
8.0.240.0030.00517.29
8.0.230.0000.00717.22
8.0.220.0000.00617.13
8.0.210.0030.00517.22
8.0.200.0030.00617.28
8.0.190.0000.00817.10
8.0.180.0000.00917.21
8.0.170.0000.00817.22
8.0.160.0040.00417.18
8.0.150.0040.00417.13
8.0.140.0000.00717.18
8.0.130.0000.00613.64
8.0.120.0070.00017.18
8.0.110.0040.00417.02
8.0.100.0040.00417.05
8.0.90.0070.00017.23
8.0.80.0060.00917.20
8.0.70.0040.00417.13
8.0.60.0050.00317.06
8.0.50.0040.00417.23
8.0.30.0050.01517.19
8.0.20.0100.00917.41
8.0.10.0050.00217.31
8.0.00.0080.01016.92
7.4.330.0000.00515.11
7.4.320.0000.00716.54
7.4.300.0000.00616.61
7.4.290.0030.00316.66
7.4.280.0050.00516.66
7.4.270.0000.00716.71
7.4.260.0040.00416.59
7.4.250.0040.00416.52
7.4.240.0050.00216.67
7.4.230.0030.00316.61
7.4.220.0110.00716.57
7.4.210.0070.00716.71
7.4.200.0020.00516.74
7.4.160.0150.00016.86
7.4.150.0120.01517.40
7.4.140.0100.00717.86
7.4.130.0070.01016.67
7.4.120.0030.01616.72
7.4.110.0070.01616.58
7.4.100.0100.00616.77
7.4.90.0120.00416.66
7.4.80.0070.01119.39
7.4.70.0110.00716.60
7.4.60.0070.01016.54
7.4.50.0000.00516.52
7.4.40.0090.00616.50
7.4.30.0100.00716.88
7.4.00.0030.01415.16
7.3.330.0030.00313.50
7.3.320.0000.00713.29
7.3.310.0030.00316.50
7.3.300.0040.00416.54
7.3.290.0060.00916.57
7.3.280.0090.00916.50
7.3.270.0120.01217.40
7.3.260.0120.00816.58
7.3.250.0070.01116.60
7.3.240.0070.01616.55
7.3.230.0130.00316.85
7.3.210.0130.00616.59
7.3.200.0170.00719.39
7.3.190.0090.00616.63
7.3.180.0140.00316.63
7.3.170.0170.00416.71
7.3.160.0120.00416.67
7.3.10.0080.00316.50
7.3.00.0030.00616.34
7.2.330.0130.00716.93
7.2.320.0100.00716.84
7.2.310.0120.00916.51
7.2.300.0100.01016.50
7.2.290.0130.00616.75
7.2.130.0000.01217.16
7.2.120.0070.00716.74
7.2.110.0060.00316.83
7.2.100.0030.00616.90
7.2.90.0060.00616.66
7.2.80.0080.00317.05
7.2.70.0000.01316.92
7.2.60.0060.00817.03
7.2.50.0070.00716.96
7.2.40.0090.00316.96
7.2.30.0000.01616.86
7.2.20.0030.01217.13
7.2.10.0060.00917.12
7.2.00.0060.00618.15
7.1.250.0040.00715.91
7.1.200.0120.00015.58
7.1.100.0060.00618.16
7.1.70.0000.00817.05
7.1.60.0110.01519.40
7.1.50.0070.01816.93
7.1.00.0070.07322.27
7.0.200.0070.00016.59
7.0.140.0070.07022.09
7.0.60.0170.07719.97
7.0.50.0100.07717.91
7.0.40.0000.04720.24
7.0.30.0200.04020.15
7.0.20.0200.05720.33
7.0.10.0100.08720.24
7.0.00.0070.05320.32
5.6.280.0030.07321.07
5.6.210.0030.05020.53
5.6.200.0100.03318.14
5.6.190.0000.05720.51
5.6.180.0300.04320.61
5.6.170.0200.04020.73
5.6.160.0030.09020.50
5.6.150.0000.09018.14
5.6.140.0000.04018.19
5.6.130.0070.08718.14
5.6.120.0170.07721.07
5.6.110.0100.07321.04
5.6.100.0030.05721.02
5.6.90.0100.05721.01
5.6.80.0100.03320.41
5.5.350.4330.03020.43
5.5.340.0130.07717.94
5.5.330.0170.07320.21
5.5.320.3000.04320.19
5.5.310.0370.06020.34
5.5.300.0000.04717.94
5.5.290.0100.04717.94
5.5.280.0130.04320.70
5.5.270.0030.05020.75
5.5.260.0130.07320.88
5.5.250.0130.07320.73
5.5.240.0000.08020.31
5.4.450.0300.05019.53
5.4.440.0270.03719.39
5.4.430.0100.04719.63
5.4.420.0400.04019.45
5.4.410.0530.04719.50
5.4.400.0330.05018.98
5.4.390.0200.04719.09
5.4.380.0170.05718.49
5.4.370.0170.05718.48
5.4.360.0230.05018.52
5.4.350.0130.06318.57
5.4.340.0200.06018.58
5.4.320.0080.03612.53
5.4.310.0070.03712.52
5.4.300.0070.03512.53
5.4.290.0050.03912.53
5.4.280.0100.03212.43
5.4.270.0070.03512.42
5.4.260.0060.03712.42
5.4.250.0030.04012.42
5.4.240.0090.03312.43
5.4.230.0070.03612.41
5.4.220.0060.03612.42
5.4.210.0090.04712.41
5.4.200.0050.03812.41
5.4.190.0070.05112.41
5.4.180.0070.03412.41
5.4.170.0030.03812.42
5.4.160.0070.03612.41
5.4.150.0060.03412.41
5.4.140.0080.03412.09
5.4.130.0050.03512.08
5.4.120.0040.03612.04
5.4.110.0040.03612.04
5.4.100.0040.03612.04
5.4.90.0060.03512.04
5.4.80.0070.03512.04
5.4.70.0020.03812.03
5.4.60.0060.03412.03
5.4.50.0040.03612.04
5.4.40.0060.03412.02
5.4.30.0080.03312.01
5.4.20.0060.03512.02
5.4.10.0060.03412.02
5.4.00.0030.03811.51
5.3.290.0020.04212.80
5.3.280.0060.03712.71
5.3.270.0090.03612.73
5.3.260.0050.03912.73
5.3.250.0070.03512.73
5.3.240.0060.03612.72
5.3.230.0090.04312.72
5.3.220.0040.03812.68
5.3.210.0060.03912.69
5.3.200.0060.04112.69
5.3.190.0060.03712.69
5.3.180.0080.03412.68
5.3.170.0020.04012.68
5.3.160.0050.03712.68
5.3.150.0070.03512.68
5.3.140.0060.03512.67
5.3.130.0050.03912.66
5.3.120.0070.03712.67
5.3.110.0060.03812.66
5.3.100.0090.03412.15
5.3.90.0060.03712.13
5.3.80.0080.03712.12
5.3.70.0050.03912.12
5.3.60.0070.03512.11
5.3.50.0050.03812.05
5.3.40.0060.03612.05
5.3.30.0040.03512.02
5.3.20.0060.03411.80
5.3.10.0070.03311.75
5.3.00.0060.03611.75
5.2.170.0050.0299.24
5.2.160.0030.0319.24
5.2.150.0050.0319.24
5.2.140.0060.0299.24
5.2.130.0050.0279.20
5.2.120.0040.0299.20
5.2.110.0050.0299.21
5.2.100.0060.0269.20
5.2.90.0030.0309.20
5.2.80.0050.0309.20
5.2.70.0050.0299.20
5.2.60.0030.0319.14
5.2.50.0020.0339.11
5.2.40.0060.0279.09
5.2.30.0040.0309.07
5.2.20.0040.0289.05
5.2.10.0050.0278.95
5.2.00.0070.0398.82
5.1.60.0050.0238.11
5.1.50.0040.0258.11
5.1.40.0050.0268.09
5.1.30.0040.0268.43
5.1.20.0090.0338.46
5.1.10.0030.0328.19
5.1.00.0050.0248.19
5.0.50.0080.0166.67
5.0.40.0050.0186.52
5.0.30.0030.0326.33
5.0.20.0050.0176.30
5.0.10.0050.0186.28
5.0.00.0010.0326.27
4.4.90.0030.0154.78
4.4.80.0050.0134.75
4.4.70.0030.0154.75
4.4.60.0010.0174.75
4.4.50.0040.0144.77
4.4.40.0020.0264.70
4.4.30.0010.0174.76
4.4.20.0040.0214.84
4.4.10.0030.0154.85
4.4.00.0030.0244.76
4.3.110.0060.0124.67
4.3.100.0040.0134.66
4.3.90.0010.0194.63
4.3.80.0030.0244.59
4.3.70.0020.0154.63
4.3.60.0030.0134.63
4.3.50.0020.0164.62
4.3.40.0030.0234.54
4.3.30.0020.0163.29
4.3.20.0050.0133.26
4.3.10.0030.0143.21
4.3.00.0030.02015.62

preferences:
48.58 ms | 401 KiB | 5 Q