3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @Class : IntervalDate * @Autor : FelipeBarros<felipe.barros.pt@gmail.com> * @Description : Servico responsavel retornar os dias da semana entre o intervalo de duas datas * @Version : 1.0 [2014-09-14] * */ class IntervalDate { private $week_days = [ 'mon' => 'monday', 'tue' => 'tuesday', 'wed' => 'wednesday', 'thu' => 'thursday', 'fri' => 'friday', 'sat' => 'saturday', 'sun' => 'sunday' ]; private $start_date; private $final_date; private $n_diff_days; private $format = 'Y-m-d'; private $result = []; public function __construct($start_date, $final_date) { $this->start_date = new \DateTime($start_date); $this->final_date = new \DateTime($final_date); $this->n_diff_days = $this->final_date->diff($this->start_date)->format('%d'); } public function process($week_days) { if($this->n_diff_days) { for($i = 0; $i <= $this->n_diff_days; $i++) { if($i == 0) { $date = $this->start_date->format($this->format); $week_day = strtolower($this->start_date->format('D')); } else { $new_date = $this->start_date->modify('+1 day'); $date = $new_date->format($this->format); $week_day = strtolower($new_date->format('D')); } if(in_array($this->week_days[$week_day], $week_days)) { $this->result[] = ['date' => $date, 'day' => $this->week_days[$week_day]]; } } } return $this; } public function get() { return $this->result; } } $intervalDate = new IntervalDate('2014-10-01', '2014-10-20'); $week_days = ['monday', 'sunday']; $result = $intervalDate->process($week_days)->get(); var_dump($result);

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.0090.00616.63
8.3.50.0100.00522.97
8.3.40.0090.00618.75
8.3.30.0100.00719.21
8.3.20.0080.00020.39
8.3.10.0080.00023.64
8.3.00.0030.00519.50
8.2.180.0150.00318.54
8.2.170.0150.00622.96
8.2.160.0070.01020.34
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0080.00021.23
8.2.110.0060.00320.55
8.2.100.0040.00818.34
8.2.90.0040.00419.40
8.2.80.0080.00017.97
8.2.70.0060.00317.63
8.2.60.0040.00418.05
8.2.50.0040.00718.07
8.2.40.0040.00418.47
8.2.30.0000.00818.28
8.2.20.0040.00418.08
8.2.10.0000.00818.38
8.2.00.0030.00618.04
8.1.280.0090.00625.92
8.1.270.0030.00623.96
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.13
8.1.230.0070.00419.21
8.1.220.0080.00017.79
8.1.210.0040.00418.77
8.1.200.0030.00717.47
8.1.190.0050.00317.48
8.1.180.0080.00018.10
8.1.170.0120.00018.89
8.1.160.0040.00421.97
8.1.150.0000.00718.95
8.1.140.0040.00417.73
8.1.130.0030.00317.89
8.1.120.0000.00717.77
8.1.110.0040.00417.76
8.1.100.0000.00717.72
8.1.90.0030.00517.62
8.1.80.0000.00717.71
8.1.70.0000.00717.66
8.1.60.0000.00917.71
8.1.50.0030.00517.71
8.1.40.0030.00617.71
8.1.30.0080.00017.71
8.1.20.0030.00517.86
8.1.10.0080.00017.77
8.1.00.0000.00717.75
8.0.300.0080.00018.77
8.0.290.0070.00016.88
8.0.280.0070.00018.52
8.0.270.0040.00417.40
8.0.260.0000.00817.41
8.0.250.0040.00417.18
8.0.240.0030.00517.10
8.0.230.0030.00317.13
8.0.220.0000.00717.11
8.0.210.0040.00417.16
8.0.200.0070.00017.20
8.0.190.0000.00717.27
8.0.180.0030.00617.15
8.0.170.0030.00517.21
8.0.160.0040.00417.18
8.0.150.0000.01116.95
8.0.140.0030.00517.20
8.0.130.0000.01013.46
8.0.120.0080.00017.03
8.0.110.0030.00517.24
8.0.100.0000.00817.16
8.0.90.0000.00717.16
8.0.80.0070.01017.20
8.0.70.0080.00016.95
8.0.60.0030.00517.02
8.0.50.0040.00417.15
8.0.30.0130.01117.30
8.0.20.0080.01217.49
8.0.10.0000.00817.31
8.0.00.0120.00716.90
7.4.330.0030.00315.25
7.4.320.0030.00316.72
7.4.300.0040.00416.73
7.4.290.0040.00416.84
7.4.280.0070.00416.71
7.4.270.0080.00016.71
7.4.260.0040.00416.63
7.4.250.0060.00316.73
7.4.240.0050.00316.69
7.4.230.0030.00316.80
7.4.220.0060.01216.68
7.4.210.0070.00816.84
7.4.200.0030.00516.52
7.4.160.0090.01516.68
7.4.150.0000.01817.40
7.4.140.0150.00817.86
7.4.130.0080.01016.96
7.4.120.0130.01316.72
7.4.110.0100.00716.71
7.4.100.0060.01316.95
7.4.90.0110.00716.94
7.4.80.0100.01019.39
7.4.70.0130.01116.73
7.4.60.0130.00516.79
7.4.50.0050.00316.63
7.4.40.0080.01116.85
7.4.30.0080.01516.90
7.4.00.0060.00915.24
7.3.330.0030.00313.41
7.3.320.0050.00013.43
7.3.310.0030.00316.48
7.3.300.0000.00716.46
7.3.290.0130.00816.66
7.3.280.0120.00816.61
7.3.270.0060.01217.40
7.3.260.0110.00716.68
7.3.250.0130.00616.67
7.3.240.0180.00016.91
7.3.230.0200.00716.98
7.3.210.0120.00916.78
7.3.200.0140.01119.39
7.3.190.0150.00416.51
7.3.180.0050.01116.45
7.3.170.0090.00616.68
7.3.160.0150.00316.54
7.3.120.0100.00615.06
7.3.110.0100.00715.07
7.3.100.0000.01414.95
7.3.90.0030.01215.16
7.3.80.0030.01415.10
7.3.70.0000.01415.24
7.3.60.0000.00914.93
7.3.50.0110.00415.21
7.3.40.0000.01615.03
7.3.30.0040.00815.11
7.3.20.0080.00316.92
7.3.10.0110.00716.73
7.3.00.0000.01116.97
7.2.330.0100.01017.01
7.2.320.0130.00616.87
7.2.310.0150.00916.82
7.2.300.0060.01417.00
7.2.290.0070.01016.73
7.2.240.0000.01615.39
7.2.230.0070.01115.29
7.2.220.0080.00415.24
7.2.210.0030.01215.01
7.2.200.0040.00815.05
7.2.190.0070.01015.18
7.2.180.0040.01115.36
7.2.170.0100.00315.22
7.2.160.0070.00715.36
7.2.150.0090.00617.12
7.2.140.0040.00817.20
7.2.130.0060.00917.18
7.2.120.0030.00916.92
7.2.110.0030.01216.85
7.2.100.0070.01017.05
7.2.90.0070.00716.89
7.2.80.0030.00917.33
7.2.70.0040.01117.01
7.2.60.0030.01416.97
7.2.50.0080.00417.28
7.2.40.0030.01217.20
7.2.30.0040.01117.10
7.2.20.0070.00416.92
7.2.10.0000.01717.07
7.2.00.0070.00718.53
7.1.330.0040.01415.71
7.1.320.0000.01516.16
7.1.310.0110.00416.05
7.1.300.0000.00916.03
7.1.290.0070.00316.15
7.1.280.0030.01016.03
7.1.270.0090.00615.96
7.1.260.0030.01015.89
7.1.250.0090.00615.97
7.1.100.0150.00418.34
7.1.70.0030.00617.43
7.1.60.0000.02419.46
7.1.50.0130.01017.39
7.1.00.0100.07022.50
7.0.200.0040.00416.88
7.0.140.0030.07022.12
7.0.60.0030.04720.05
7.0.50.0070.07317.88
7.0.40.0070.06020.27
7.0.30.0370.04320.02
7.0.20.0230.04320.10
7.0.10.0030.04320.33
7.0.00.0000.05320.25
5.6.280.0130.06321.13
5.6.210.0000.04720.54
5.6.200.0030.04318.22
5.6.190.0130.08320.47
5.6.180.0400.04720.60
5.6.170.0270.05020.54
5.6.160.0100.07720.48
5.6.150.0100.07718.21
5.6.140.0130.08018.27
5.6.130.0100.08018.09
5.6.120.0000.04320.81
5.6.110.0100.07720.95
5.6.100.0130.07721.02
5.6.90.0030.08721.14
5.6.80.0130.05320.39
5.5.350.0230.07720.45
5.5.340.0070.03717.98
5.5.330.0070.08720.21
5.5.320.0330.04020.31
5.5.310.0270.07720.29
5.5.300.0070.03717.99
5.5.290.0170.04318.04
5.5.280.0030.07720.98
5.5.270.0130.06320.90
5.5.260.0100.06020.97
5.5.250.0030.05020.59
5.5.240.0100.04320.20
5.4.450.0330.04719.32
5.4.440.0230.04719.55
5.4.430.0230.04719.40
5.4.420.0130.04719.47
5.4.410.0100.04719.50
5.4.400.0270.04019.23
5.4.390.0200.03719.23
5.4.380.0300.05318.76
5.4.370.0400.07318.74
5.4.360.0370.05718.76
5.4.350.0430.07318.61
5.4.340.0300.06318.71
5.4.320.0110.03312.52
5.4.310.0090.04112.51
5.4.300.0040.04312.52
5.4.290.0070.04312.51
5.4.280.0030.04012.41
5.4.270.0080.03812.41
5.4.260.0060.04112.41
5.4.250.0040.04012.41
5.4.240.0090.03312.41
5.4.230.0040.04012.40
5.4.220.0090.03312.40
5.4.210.0060.03512.40
5.4.200.0070.03812.41
5.4.190.0040.03812.40
5.4.180.0080.03612.40
5.4.170.0040.04612.41
5.4.160.0100.03612.41
5.4.150.0040.04212.40
5.4.140.0070.03812.08
5.4.130.0080.03612.08
5.4.120.0140.02912.03
5.4.110.0080.04212.03
5.4.100.0090.04412.03
5.4.90.0050.04012.03
5.4.80.0070.03612.03
5.4.70.0050.04412.02
5.4.60.0040.03712.02
5.4.50.0030.03812.03
5.4.40.0050.04812.01
5.4.30.0060.03812.00
5.4.20.0120.03512.00
5.4.10.0060.04012.00
5.4.00.0060.03511.49
5.3.290.0050.04112.80
5.3.280.0070.03712.71
5.3.270.0070.03812.72
5.3.260.0060.04012.72
5.3.250.0100.03312.72
5.3.240.0090.03912.72
5.3.230.0100.03812.71
5.3.220.0080.03512.68
5.3.210.0070.04412.68
5.3.200.0080.03612.68
5.3.190.0110.03612.68
5.3.180.0080.03612.68
5.3.170.0100.04012.67
5.3.160.0040.03812.68
5.3.150.0060.04012.67
5.3.140.0100.04012.66
5.3.130.0070.04012.66
5.3.120.0050.04112.66
5.3.110.0090.03512.66
5.3.100.0060.04312.12
5.3.90.0060.04412.10
5.3.80.0070.04012.09
5.3.70.0060.03812.09
5.3.60.0080.03412.08
5.3.50.0080.03412.02
5.3.40.0090.03412.02
5.3.30.0040.04011.98
5.3.20.0050.03811.76
5.3.10.0070.03611.73
5.3.00.0100.03611.71
5.2.170.0050.0309.22
5.2.160.0070.0329.22
5.2.150.0070.0289.21
5.2.140.0070.0309.21
5.2.130.0050.0329.18
5.2.120.0060.0299.18
5.2.110.0050.0289.18
5.2.100.0060.0299.18
5.2.90.0060.0279.18
5.2.80.0060.0299.17
5.2.70.0050.0319.17
5.2.60.0070.0299.13
5.2.50.0060.0309.10
5.2.40.0060.0289.07
5.2.30.0070.0289.04
5.2.20.0070.0269.04
5.2.10.0060.0278.94
5.2.00.0020.0358.80
5.1.60.0050.0238.09
5.1.50.0050.0248.09
5.1.40.0050.0238.06
5.1.30.0040.0268.42
5.1.20.0050.0268.44
5.1.10.0050.0258.16
5.1.00.0050.0288.16
5.0.50.0020.0216.64
5.0.40.0060.0216.50
5.0.30.0040.0336.31
5.0.20.0020.0246.28
5.0.10.0020.0216.26
5.0.00.0060.0286.25
4.4.90.0020.0164.78
4.4.80.0040.0234.75
4.4.70.0040.0174.76
4.4.60.0020.0164.76
4.4.50.0030.0154.77
4.4.40.0020.0264.71
4.4.30.0030.0154.76
4.4.20.0020.0164.85
4.4.10.0030.0204.85
4.4.00.0030.0244.76
4.3.110.0040.0144.67
4.3.100.0060.0124.67
4.3.90.0040.0184.63
4.3.80.0030.0244.58
4.3.70.0030.0144.63
4.3.60.0030.0144.63
4.3.50.0040.0144.63
4.3.40.0010.0274.54
4.3.30.0020.0173.30
4.3.20.0020.0173.28
4.3.10.0030.0243.23
4.3.00.0030.01318.23

preferences:
46.83 ms | 401 KiB | 5 Q