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_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.0120.00918.58
8.3.50.0090.01122.91
8.3.40.0120.00319.07
8.3.30.0100.00718.81
8.3.20.0080.00020.21
8.3.10.0080.00023.44
8.3.00.0040.00419.51
8.2.180.0190.00416.88
8.2.170.0140.00722.96
8.2.160.0070.01020.33
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00421.09
8.2.110.0030.00620.97
8.2.100.0040.00718.03
8.2.90.0030.00519.34
8.2.80.0080.00017.97
8.2.70.0060.00317.88
8.2.60.0080.00018.05
8.2.50.0030.00518.07
8.2.40.0030.00520.07
8.2.30.0030.00618.18
8.2.20.0000.00818.07
8.2.10.0000.00818.23
8.2.00.0040.00418.18
8.1.280.0040.01825.92
8.1.270.0030.00623.99
8.1.260.0070.00026.35
8.1.250.0050.00328.09
8.1.240.0060.00322.14
8.1.230.0120.00017.88
8.1.220.0050.00318.04
8.1.210.0040.00418.77
8.1.200.0140.00017.60
8.1.190.0050.00317.48
8.1.180.0080.00018.10
8.1.170.0050.00318.84
8.1.160.0030.00522.08
8.1.150.0000.00718.89
8.1.140.0040.00417.63
8.1.130.0030.00317.94
8.1.120.0040.00417.80
8.1.110.0040.00417.64
8.1.100.0080.00017.56
8.1.90.0040.00417.58
8.1.80.0000.00717.70
8.1.70.0000.00817.64
8.1.60.0040.00417.80
8.1.50.0050.00517.63
8.1.40.0000.00817.69
8.1.30.0000.00917.75
8.1.20.0000.00817.88
8.1.10.0030.00617.71
8.1.00.0030.00617.75
8.0.300.0030.00618.77
8.0.290.0040.00417.00
8.0.280.0000.00718.52
8.0.270.0000.00817.41
8.0.260.0030.00317.39
8.0.250.0040.00417.16
8.0.240.0050.00217.19
8.0.230.0000.00717.25
8.0.220.0030.00317.20
8.0.210.0080.00017.09
8.0.200.0080.00017.13
8.0.190.0050.00317.28
8.0.180.0030.00617.18
8.0.170.0040.00417.13
8.0.160.0000.00817.26
8.0.150.0060.00317.02
8.0.140.0040.00417.16
8.0.130.0060.00013.57
8.0.120.0000.00817.14
8.0.110.0000.00717.12
8.0.100.0000.00817.11
8.0.90.0000.00717.20
8.0.80.0140.01017.18
8.0.70.0040.00416.99
8.0.60.0000.00717.20
8.0.50.0020.00517.25
8.0.30.0130.00817.41
8.0.20.0170.00617.50
8.0.10.0080.00017.23
8.0.00.0090.00817.08
7.4.330.0050.00015.18
7.4.320.0040.00416.75
7.4.300.0030.00316.79
7.4.290.0050.00216.70
7.4.280.0070.00316.82
7.4.270.0000.00716.73
7.4.260.0040.00416.68
7.4.250.0000.00816.64
7.4.240.0050.00316.78
7.4.230.0030.00316.53
7.4.220.0120.00616.73
7.4.210.0140.00616.75
7.4.200.0040.00416.49
7.4.160.0120.00616.84
7.4.150.0080.01317.40
7.4.140.0080.01017.86
7.4.130.0130.00416.76
7.4.120.0070.01116.70
7.4.110.0100.01416.90
7.4.100.0080.00816.76
7.4.90.0090.00916.49
7.4.80.0110.00719.39
7.4.70.0130.01216.91
7.4.60.0070.01016.63
7.4.50.0030.00616.62
7.4.40.0090.00916.84
7.4.30.0160.00016.77
7.4.00.0070.00715.29
7.3.330.0070.00013.54
7.3.320.0060.00013.68
7.3.310.0050.00316.53
7.3.300.0000.00716.69
7.3.290.0080.00916.68
7.3.280.0090.00916.67
7.3.270.0110.00717.40
7.3.260.0150.00316.63
7.3.250.0100.00916.66
7.3.240.0150.00316.66
7.3.230.0000.01716.63
7.3.210.0160.00316.74
7.3.200.0140.00419.39
7.3.190.0130.00316.61
7.3.180.0030.01316.71
7.3.170.0130.00916.70
7.3.160.0100.00716.59
7.2.330.0030.01716.88
7.2.320.0090.00916.74
7.2.310.0060.01617.01
7.2.300.0110.00616.81
7.2.290.0000.01716.99
7.2.60.0130.00616.94
7.1.200.0030.01116.07
7.1.70.0030.01017.53
7.1.60.0030.02119.40
7.1.50.0030.02217.21
7.1.00.0030.07722.41
7.0.200.0080.00017.00
7.0.140.0070.07022.11
7.0.60.0170.07319.95
7.0.50.0100.06717.88
7.0.40.0100.07720.35
7.0.30.0270.07720.24
7.0.20.0070.05020.24
7.0.10.0070.06720.06
7.0.00.0030.09320.05
5.6.280.0000.07721.07
5.6.210.0130.05320.74
5.6.200.0130.03318.19
5.6.190.0070.08020.48
5.6.180.3770.04320.39
5.6.170.0300.03320.51
5.6.160.0030.06320.51
5.6.150.0030.04318.19
5.6.140.0170.07718.19
5.6.130.0070.07018.16
5.6.120.0100.05320.92
5.6.110.0030.04721.00
5.6.100.0030.09321.13
5.6.90.0100.08720.96
5.6.80.0070.07720.39
5.5.350.0270.07720.43
5.5.340.0070.05317.98
5.5.330.0030.06720.35
5.5.320.0200.05320.24
5.5.310.0230.05020.37
5.5.300.0030.04018.01
5.5.290.0100.04717.98
5.5.280.0000.09020.91
5.5.270.0100.03720.89
5.5.260.0070.06720.89
5.5.250.0070.08320.82
5.5.240.3630.04320.29
5.4.450.0500.06319.65
5.4.440.0230.05019.17
5.4.430.0330.07019.62
5.4.420.0200.05719.47
5.4.410.0200.08319.35
5.4.400.0230.05719.13
5.4.390.0200.05719.28
5.4.380.0830.06318.61
5.4.370.0970.05018.63
5.4.360.0800.05318.73
5.4.350.0700.05718.77
5.4.340.0730.05018.49
5.4.320.0070.04812.52
5.4.310.0090.03612.52
5.4.300.0090.04412.52
5.4.290.0100.05312.52
5.4.280.0050.03512.41
5.4.270.0050.03612.41
5.4.260.0080.05612.42
5.4.250.0030.04112.42
5.4.240.0070.04512.41
5.4.230.0080.03512.41
5.4.220.0080.03412.41
5.4.210.0040.03612.41
5.4.200.0050.03912.41
5.4.190.0070.03612.41
5.4.180.0040.03712.40
5.4.170.0060.03512.42
5.4.160.0060.03512.41
5.4.150.0060.04012.41
5.4.140.0050.03912.10
5.4.130.0060.03512.09
5.4.120.0060.03912.04
5.4.110.0090.04212.04
5.4.100.0060.03912.04
5.4.90.0080.03912.04
5.4.80.0070.04612.04
5.4.70.0110.04712.03
5.4.60.0090.03212.03
5.4.50.0080.03412.03
5.4.40.0050.03612.02
5.4.30.0070.03612.01
5.4.20.0020.04812.02
5.4.10.0070.04212.02
5.4.00.0060.03411.50
5.3.290.0080.04512.80
5.3.280.0100.03812.71
5.3.270.0100.03612.72
5.3.260.0070.04412.72
5.3.250.0110.04112.72
5.3.240.0060.03712.72
5.3.230.0040.03912.71
5.3.220.0060.03712.68
5.3.210.0040.04012.68
5.3.200.0030.03912.68
5.3.190.0040.03912.68
5.3.180.0050.03712.68
5.3.170.0030.03812.68
5.3.160.0050.03612.68
5.3.150.0050.03712.68
5.3.140.0060.03612.67
5.3.130.0060.03812.66
5.3.120.0040.04012.66
5.3.110.0070.03712.66
5.3.100.0090.03412.15
5.3.90.0090.03212.13
5.3.80.0060.03912.12
5.3.70.0090.03512.12
5.3.60.0090.03912.10
5.3.50.0060.03812.05
5.3.40.0080.03512.05
5.3.30.0030.03812.02
5.3.20.0060.03511.79
5.3.10.0070.03411.75
5.3.00.0040.03711.74
5.2.170.0060.0309.24
5.2.160.0080.0269.23
5.2.150.0070.0349.24
5.2.140.0040.0419.23
5.2.130.0030.0309.20
5.2.120.0060.0379.20
5.2.110.0040.0419.21
5.2.100.0030.0419.20
5.2.90.0060.0399.20
5.2.80.0020.0329.20
5.2.70.0090.0419.20
5.2.60.0090.0379.14
5.2.50.0010.0339.11
5.2.40.0070.0279.09
5.2.30.0030.0329.07
5.2.20.0070.0269.06
5.2.10.0040.0348.96
5.2.00.0020.0308.83
5.1.60.0070.0328.11
5.1.50.0070.0228.11
5.1.40.0040.0278.09
5.1.30.0030.0298.43
5.1.20.0040.0298.46
5.1.10.0040.0358.18
5.1.00.0090.0268.18
5.0.50.0030.0256.67
5.0.40.0040.0196.52
5.0.30.0050.0366.34
5.0.20.0040.0186.30
5.0.10.0020.0216.28
5.0.00.0040.0336.27
4.4.90.0010.0214.78
4.4.80.0030.0164.75
4.4.70.0050.0144.76
4.4.60.0010.0174.75
4.4.50.0030.0154.77
4.4.40.0020.0254.71
4.4.30.0050.0144.76
4.4.20.0020.0164.84
4.4.10.0040.0184.85
4.4.00.0050.0324.76
4.3.110.0020.0164.67
4.3.100.0020.0154.67
4.3.90.0020.0154.63
4.3.80.0010.0254.58
4.3.70.0020.0154.63
4.3.60.0010.0164.63
4.3.50.0030.0144.63
4.3.40.0040.0224.54
4.3.30.0020.0153.29
4.3.20.0020.0183.27
4.3.10.0020.0223.22
4.3.00.0000.02015.62

preferences:
37.53 ms | 401 KiB | 5 Q