3v4l.org

run code in 300+ PHP versions simultaneously
<?php $initialDate = DateTime::createFromFormat('U', '1409611999'); $initialDate = new DateTimeExtended($initialDate); $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.70.0000.01516.88
8.3.60.0220.00316.48
8.3.50.0160.00522.82
8.3.40.0180.00418.93
8.3.30.0120.00319.17
8.3.20.0070.00020.32
8.3.10.0030.00623.66
8.3.00.0050.00319.63
8.2.180.0140.00718.25
8.2.170.0000.01419.16
8.2.160.0140.00322.96
8.2.150.0040.00425.66
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0040.00421.10
8.2.110.0070.00422.10
8.2.100.0070.00417.97
8.2.90.0000.00820.64
8.2.80.0000.00817.97
8.2.70.0000.00918.16
8.2.60.0050.00318.05
8.2.50.0000.00818.10
8.2.40.0080.00019.96
8.2.30.0050.00318.17
8.2.20.0000.00917.93
8.2.10.0030.00518.32
8.2.00.0060.00318.10
8.1.280.0140.00325.92
8.1.270.0100.00722.03
8.1.260.0050.00326.35
8.1.250.0090.00628.09
8.1.240.0100.00022.56
8.1.230.0090.00320.85
8.1.220.0000.00817.77
8.1.210.0030.00618.95
8.1.200.0030.00617.60
8.1.190.0000.00917.48
8.1.180.0060.00318.10
8.1.170.0000.00818.68
8.1.160.0050.00321.99
8.1.150.0030.00619.03
8.1.140.0040.00417.73
8.1.130.0030.00317.99
8.1.120.0000.00717.59
8.1.110.0040.00417.68
8.1.100.0000.00717.59
8.1.90.0040.00417.66
8.1.80.0000.00717.66
8.1.70.0040.00417.52
8.1.60.0050.00517.70
8.1.50.0030.00517.54
8.1.40.0020.00517.71
8.1.30.0090.00017.65
8.1.20.0030.00617.86
8.1.10.0000.00817.74
8.1.00.0040.00417.59
8.0.300.0040.00420.02
8.0.290.0000.00817.13
8.0.280.0000.00718.42
8.0.270.0020.00517.21
8.0.260.0030.00317.43
8.0.250.0050.00217.14
8.0.240.0040.00417.24
8.0.230.0070.00017.23
8.0.220.0000.00717.20
8.0.210.0050.00317.20
8.0.200.0040.00417.13
8.0.190.0000.00917.23
8.0.180.0030.00717.14
8.0.170.0000.00817.21
8.0.160.0040.00417.27
8.0.150.0090.00017.09
8.0.140.0040.00417.03
8.0.130.0000.00613.59
8.0.120.0040.00417.04
8.0.110.0000.00717.09
8.0.100.0000.00717.05
8.0.90.0040.00417.17
8.0.80.0100.00717.11
8.0.70.0050.00317.05
8.0.60.0080.00017.13
8.0.50.0070.00017.05
8.0.30.0080.01117.30
8.0.20.0130.00717.40
8.0.10.0050.00217.17
8.0.00.0150.00616.96
7.4.330.0060.00015.14
7.4.320.0060.00016.76
7.4.300.0030.00316.63
7.4.290.0030.00316.79
7.4.280.0000.01016.67
7.4.270.0000.00716.70
7.4.260.0080.00016.58
7.4.250.0050.00316.52
7.4.240.0020.00516.67
7.4.230.0000.00816.60
7.4.220.0110.00716.71
7.4.210.0050.01116.68
7.4.200.0040.00416.57
7.4.160.0000.01616.68
7.4.150.0100.01417.40
7.4.140.0110.00717.86
7.4.130.0110.00616.79
7.4.120.0120.00516.65
7.4.110.0170.00716.57
7.4.100.0180.00016.68
7.4.90.0100.00716.62
7.4.80.0120.00619.39
7.4.70.0140.01416.70
7.4.60.0100.00716.62
7.4.50.0030.00616.80
7.4.40.0080.00816.76
7.4.30.0070.01116.80
7.4.00.0100.00815.11
7.3.330.0060.00013.33
7.3.320.0080.00013.29
7.3.310.0030.00416.41
7.3.300.0040.00416.51
7.3.290.0090.00616.54
7.3.280.0080.01216.51
7.3.270.0100.01017.40
7.3.260.0110.01516.70
7.3.250.0090.00816.64
7.3.240.0190.00616.85
7.3.230.0100.00716.43
7.3.210.0030.01416.61
7.3.200.0070.01419.39
7.3.190.0110.01116.84
7.3.180.0030.01416.70
7.3.170.0100.01316.57
7.3.160.0090.00916.52
7.3.120.0100.01015.03
7.3.110.0070.01115.04
7.3.100.0110.00715.07
7.3.90.0030.01215.11
7.3.80.0040.01114.92
7.3.70.0080.00814.99
7.3.60.0100.00615.14
7.3.50.0070.01114.84
7.3.40.0040.00415.12
7.3.30.0030.00615.04
7.3.20.0130.00316.93
7.3.10.0050.01116.67
7.3.00.0040.01016.79
7.2.330.0090.00916.72
7.2.320.0110.00617.03
7.2.310.0090.00916.96
7.2.300.0140.00317.04
7.2.290.0090.00916.66
7.2.250.0000.01715.38
7.2.240.0070.01415.26
7.2.230.0120.00915.37
7.2.220.0060.00915.27
7.2.210.0060.00915.34
7.2.200.0110.00415.35
7.2.190.0070.01015.38
7.2.180.0040.01215.17
7.2.170.0030.01315.41
7.2.130.0060.00617.18
7.2.120.0080.00817.17
7.2.110.0040.01117.21
7.2.100.0040.01116.98
7.2.90.0080.00817.02
7.2.80.0130.00516.99
7.2.70.0080.00317.12
7.2.60.0050.00617.03
7.2.50.0070.00417.27
7.2.40.0090.00317.05
7.2.30.0030.00917.29
7.2.20.0110.00317.11
7.2.10.0000.01317.16
7.2.00.0220.00518.29
7.1.330.0090.00615.66
7.1.320.0030.00715.95
7.1.310.0130.00016.05
7.1.300.0060.00916.12
7.1.290.0110.00016.02
7.1.280.0120.00316.10
7.1.270.0030.01015.96
7.1.260.0090.00615.66
7.1.250.0070.00315.99
7.1.200.0000.01416.10
7.1.100.0140.00418.28
7.1.70.0000.00717.11
7.1.60.0070.01819.40
7.1.50.0070.01617.23
7.1.00.0000.08022.44
7.0.200.0030.00717.04
7.0.140.0000.07722.01
7.0.60.0200.07319.83
7.0.50.0100.04717.92
7.0.40.0070.04020.23
7.0.30.0400.05720.09
7.0.20.0400.07320.21
7.0.10.0070.07020.16
7.0.00.0100.03720.36
5.6.280.0030.07320.84
5.6.210.0000.04320.59
5.6.200.0100.07718.18
5.6.190.0100.07320.58
5.6.180.0130.04720.61
5.6.170.0230.07720.71
5.6.160.0030.06020.54
5.6.150.0070.08718.19
5.6.140.0030.06018.18
5.6.130.0030.08718.14
5.6.120.0030.07321.00
5.6.110.0070.08321.13
5.6.100.0100.06721.03
5.6.90.0030.05020.99
5.6.80.0130.07320.53
5.5.350.0070.07720.55
5.5.340.0100.05717.95
5.5.330.0070.08720.19
5.5.320.0000.08720.35
5.5.310.0400.06720.23
5.5.300.0170.06317.93
5.5.290.0100.04017.94
5.5.280.0030.05021.00
5.5.270.0000.04321.00
5.5.260.0100.07020.88
5.5.250.0100.06020.60
5.5.240.4000.03320.36
5.4.450.0200.04319.65
5.4.440.0200.05019.31
5.4.430.0470.05019.54
5.4.420.0430.04319.20
5.4.410.0230.04319.39
5.4.400.0070.05019.15
5.4.390.0270.04018.99
5.4.380.0770.06718.53
5.4.370.0770.06018.62
5.4.360.0970.05318.60
5.4.350.0800.06318.67
5.4.340.0630.04718.70
5.4.320.0070.03612.52
5.4.310.0090.03812.52
5.4.300.0070.03612.52
5.4.290.0040.04012.52
5.4.280.0030.03812.41
5.4.270.0050.03712.41
5.4.260.0050.03812.42
5.4.250.0020.04112.41
5.4.240.0050.03712.42
5.4.230.0060.03712.41
5.4.220.0070.03612.41
5.4.210.0080.04212.41
5.4.200.0070.04912.41
5.4.190.0070.03512.40
5.4.180.0040.03812.41
5.4.170.0080.04912.42
5.4.160.0050.04612.41
5.4.150.0040.03712.41
5.4.140.0040.04012.09
5.4.130.0050.03512.08
5.4.120.0060.03412.04
5.4.110.0080.03312.04
5.4.100.0040.04112.03
5.4.90.0050.03812.04
5.4.80.0070.03612.04
5.4.70.0090.03212.03
5.4.60.0060.03512.04
5.4.50.0030.03812.04
5.4.40.0070.03312.02
5.4.30.0050.03612.02
5.4.20.0080.03712.02
5.4.10.0030.03812.02
5.4.00.0050.03611.51
5.3.290.0040.04112.80
5.3.280.0070.04612.71
5.3.270.0050.04612.72
5.3.260.0080.04512.72
5.3.250.0060.04612.72
5.3.240.0070.03612.72
5.3.230.0070.04312.71
5.3.220.0070.03912.68
5.3.210.0050.04812.68
5.3.200.0080.04412.68
5.3.190.0090.04012.68
5.3.180.0050.03612.68
5.3.170.0050.03812.68
5.3.160.0070.03512.68
5.3.150.0060.03612.68
5.3.140.0070.04312.66
5.3.130.0050.03912.66
5.3.120.0040.04012.66
5.3.110.0060.04012.66
5.3.100.0070.04012.14
5.3.90.0080.03412.13
5.3.80.0050.03812.11
5.3.70.0060.03712.11
5.3.60.0040.03812.10
5.3.50.0060.04612.05
5.3.40.0060.03612.05
5.3.30.0070.03312.02
5.3.20.0070.03411.79
5.3.10.0030.03711.75
5.3.00.0040.03711.74
5.2.170.0050.0429.24
5.2.160.0070.0399.24
5.2.150.0040.0419.24
5.2.140.0060.0389.23
5.2.130.0040.0299.20
5.2.120.0050.0289.20
5.2.110.0020.0319.20
5.2.100.0070.0269.20
5.2.90.0030.0309.20
5.2.80.0050.0319.20
5.2.70.0040.0319.20
5.2.60.0040.0309.14
5.2.50.0030.0329.11
5.2.40.0040.0439.09
5.2.30.0060.0349.07
5.2.20.0100.0459.06
5.2.10.0070.0308.96
5.2.00.0080.0378.83
5.1.60.0030.0258.11
5.1.50.0090.0258.11
5.1.40.0040.0258.09
5.1.30.0030.0278.44
5.1.20.0040.0278.46
5.1.10.0050.0288.19
5.1.00.0050.0268.19
5.0.50.0040.0216.66
5.0.40.0040.0196.53
5.0.30.0050.0326.34
5.0.20.0040.0196.30
5.0.10.0050.0236.28
5.0.00.0030.0316.27
4.4.90.0010.0174.78
4.4.80.0030.0214.75
4.4.70.0070.0164.76
4.4.60.0040.0154.75
4.4.50.0040.0144.77
4.4.40.0040.0254.71
4.4.30.0020.0164.76
4.4.20.0030.0184.84
4.4.10.0000.0184.85
4.4.00.0030.0244.76
4.3.110.0040.0144.67
4.3.100.0050.0124.66
4.3.90.0020.0154.63
4.3.80.0030.0244.59
4.3.70.0040.0124.63
4.3.60.0030.0144.63
4.3.50.0020.0164.63
4.3.40.0010.0254.54
4.3.30.0020.0163.29
4.3.20.0010.0173.26
4.3.10.0020.0153.22
4.3.00.0070.01715.62

preferences:
46.43 ms | 401 KiB | 5 Q