3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getStartOfWeekDate($date = null) { if ($date instanceof \DateTime) { $date = clone $date; } else if (!$date) { $date = new \DateTime(); } else { $date = new \DateTime($date); } $date->setTime(0, 0, 0); if ($date->format('N') == 1) { // If the date is already a Monday, return it as-is return $date; } else { // Otherwise, return the date of the nearest Monday in the past // This includes Sunday in the previous week instead of it being the start of a new week return $date->modify('last monday'); } } echo getStartOfWeekDate(new \DateTime('2020-12-06'))->format('Y-m-d');

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.0030.01218.31
8.3.50.0070.01118.15
8.3.40.0170.00321.93
8.3.30.0090.00618.79
8.3.20.0000.00724.18
8.3.10.0040.00424.66
8.3.00.0070.00426.16
8.2.180.0140.00025.92
8.2.170.0090.00619.21
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0030.00526.35
8.2.110.0030.00719.39
8.2.100.0000.01117.84
8.2.90.0050.00318.16
8.2.80.0000.00817.97
8.2.70.0060.00318.16
8.2.60.0050.00318.05
8.2.50.0000.00818.07
8.2.40.0000.00718.28
8.2.30.0040.00418.18
8.2.20.0030.00618.24
8.2.10.0040.00419.39
8.2.00.0000.00719.26
8.1.280.0090.00925.92
8.1.270.0040.00424.01
8.1.260.0040.00428.09
8.1.250.0050.00328.09
8.1.240.0030.00722.54
8.1.230.0040.00721.00
8.1.220.0050.00317.74
8.1.210.0030.00619.00
8.1.200.0050.00317.48
8.1.190.0080.00019.06
8.1.180.0040.00418.10
8.1.170.0040.00418.71
8.1.160.0000.00819.00
8.1.150.0040.00419.14
8.1.140.0070.00019.02
8.1.130.0030.00520.33
8.1.120.0040.00417.64
8.1.110.0040.00417.63
8.1.100.0000.00817.69
8.1.90.0000.00817.58
8.1.80.0030.00617.73
8.1.70.0030.00317.77
8.1.60.0060.00317.77
8.1.50.0040.00417.61
8.1.40.0040.00417.69
8.1.30.0080.00017.86
8.1.20.0040.00417.86
8.1.10.0040.00417.69
8.1.00.0000.00717.73
8.0.300.0000.00819.94
8.0.290.0000.00816.88
8.0.280.0030.00318.46
8.0.270.0070.00018.26
8.0.260.0030.00318.63
8.0.250.0030.00317.26
8.0.240.0050.00317.13
8.0.230.0030.00317.21
8.0.220.0030.00617.03
8.0.210.0050.00317.13
8.0.200.0000.00717.20
8.0.190.0000.00717.05
8.0.180.0030.00317.16
8.0.170.0000.00817.06
8.0.160.0040.00417.20
8.0.150.0050.00717.07
8.0.140.0070.00017.12
8.0.130.0000.00613.52
8.0.120.0040.00417.09
8.0.110.0040.00417.22
8.0.100.0000.00717.10
8.0.90.0070.00017.16
8.0.80.0090.00617.12
8.0.70.0040.00417.01
8.0.60.0000.00717.14
8.0.50.0030.00617.18
8.0.30.0090.00917.54
8.0.20.0100.00917.31
8.0.10.0000.00817.21
8.0.00.0220.00716.88
7.4.330.0000.00515.55
7.4.320.0000.00716.70
7.4.300.0040.00416.77
7.4.290.0050.00216.65
7.4.280.0050.00316.71
7.4.270.0060.00316.72
7.4.260.0050.00316.60
7.4.250.0000.00716.75
7.4.240.0000.00716.82
7.4.230.0000.00716.90
7.4.220.0030.00316.81
7.4.210.0050.01016.70
7.4.200.0030.00316.64
7.4.130.0190.00416.62
7.4.120.0190.00416.71
7.4.110.0160.01116.59
7.4.100.0120.01116.67
7.4.90.0100.01116.84
7.4.80.0070.01616.81
7.4.70.0080.01416.73
7.4.60.0140.00916.72
7.4.50.0170.01716.81
7.4.40.0100.01116.61
7.4.30.0100.01316.79
7.4.20.0100.01116.74
7.4.10.0100.01016.81
7.4.00.0100.01516.54
7.3.330.0060.00016.43
7.3.320.0060.00013.55
7.3.310.0000.00816.55
7.3.300.0070.00016.42
7.3.290.0100.00816.57
7.3.260.0150.00916.81
7.3.250.0110.01316.58
7.3.240.0170.00616.57
7.3.230.0100.01216.72
7.3.220.0120.01016.93
7.3.210.0110.01116.67
7.3.200.0110.00816.65
7.3.190.0080.01716.64
7.3.180.0110.01116.75
7.3.170.0120.01216.59
7.3.160.0190.00316.56
7.3.150.0180.00516.70
7.3.140.0130.01116.63
7.3.130.0180.00616.69
7.3.120.0100.01116.63
7.3.110.0160.00816.58
7.3.100.0130.01216.58
7.3.90.0120.01116.56
7.3.80.0160.01116.49
7.3.70.0110.01216.42
7.3.60.0140.01016.61
7.3.50.0140.00716.47
7.3.40.0120.01216.48
7.3.30.0150.01016.63
7.3.20.0170.01116.56
7.3.10.0160.01116.57
7.3.00.0070.01416.43
7.2.340.0290.01516.52
7.2.330.0190.01916.89
7.2.320.0360.01216.66
7.2.310.0280.01316.90
7.2.300.0330.00716.91
7.2.290.0230.01816.68
7.2.280.0300.00616.92
7.2.270.0260.01316.69
7.2.260.0240.01516.73
7.2.250.0280.01117.04
7.2.240.0330.01316.71
7.2.230.0230.01916.83
7.2.220.0340.00416.64
7.2.210.0250.01216.89
7.2.200.0390.00716.74
7.2.190.0270.01216.70
7.2.180.0300.00916.82
7.2.170.0330.00416.82
7.2.160.0290.01116.67
7.2.150.0300.01116.74
7.2.140.0280.00816.89
7.2.130.0360.00317.00
7.2.120.0290.00716.96
7.2.110.0290.01216.79
7.2.100.0340.00516.75
7.2.90.0440.01116.74
7.2.80.0290.01116.85
7.2.70.0300.01116.90
7.2.60.0210.01816.74
7.2.50.0330.01116.86
7.2.40.0170.02316.78
7.2.30.0300.01117.02
7.2.20.0320.01116.94
7.2.10.0280.01816.72
7.2.00.0380.00416.80
7.1.330.0320.00715.79
7.1.320.0320.00615.76
7.1.310.0280.00615.75
7.1.300.0310.00615.69
7.1.290.0260.00915.77
7.1.280.0250.01215.86
7.1.270.0240.01215.69
7.1.260.0230.01315.73
7.1.250.0260.01115.63
7.1.240.0250.00615.79
7.1.230.0240.00915.84
7.1.220.0310.00615.80
7.1.210.0320.01015.73
7.1.200.0240.01215.75
7.1.190.0260.01015.65
7.1.180.0300.00715.82
7.1.170.0280.01215.69
7.1.160.0530.00615.77
7.1.150.0310.00815.55
7.1.140.0310.01315.93
7.1.130.0210.01715.69
7.1.120.0240.01515.66
7.1.110.0230.01715.88
7.1.100.0210.01815.70
7.1.90.0280.01115.85
7.1.80.0310.00515.57
7.1.70.0420.00815.42
7.1.60.0320.00415.74
7.1.50.0250.01115.89
7.1.40.0300.00915.72
7.1.30.0300.00415.78
7.1.20.0250.01115.76
7.1.10.0210.01215.70
7.1.00.0310.00415.72
7.0.330.0470.00615.51
7.0.320.0400.00315.46
7.0.310.0210.01515.46
7.0.300.0250.01415.34
7.0.290.0210.01415.31
7.0.280.0210.01515.43
7.0.270.0270.01015.29
7.0.260.0250.00915.29
7.0.250.0290.01115.45
7.0.240.0260.00715.45
7.0.230.0190.01615.47
7.0.220.0290.00215.39
7.0.210.0160.01615.41
7.0.200.0210.01315.41
7.0.190.0260.00815.53
7.0.180.0220.01315.50
7.0.170.0410.00815.50
7.0.160.0190.01615.47
7.0.150.0240.01515.36
7.0.140.0300.00415.45
7.0.130.0230.00915.49
7.0.120.0370.00315.46
7.0.110.0230.00815.46
7.0.100.0200.01215.42
7.0.90.0250.00815.41
7.0.80.0180.01415.45
7.0.70.0350.00315.34
7.0.60.0220.01115.62
7.0.50.0240.00715.29
7.0.40.0190.01715.27
7.0.30.0180.01215.34
7.0.20.0500.02215.38
7.0.10.0250.00615.39
7.0.00.0220.01115.25
5.6.400.0130.02015.81
5.6.390.0280.00815.94
5.6.380.0160.02016.30
5.6.370.0230.01116.21
5.6.360.0310.00816.25
5.6.350.0300.00316.02
5.6.340.0390.00315.88
5.6.330.0210.01716.19
5.6.320.0260.01616.04
5.6.310.0200.01416.13
5.6.300.0210.01816.07
5.6.290.0270.01316.03
5.6.280.0330.00716.13
5.6.270.0230.01616.15
5.6.260.0220.01316.01
5.6.250.0180.01516.16
5.6.240.0230.01416.04
5.6.230.0330.00416.18
5.6.220.0210.01316.01
5.6.210.0270.00915.91
5.6.200.0290.00915.95
5.6.190.0170.02116.08
5.6.180.0310.00615.96
5.6.170.0260.00616.05
5.6.160.0210.01816.25
5.6.150.0230.01216.00
5.6.140.0250.01216.00
5.6.130.0240.01115.95
5.6.120.0380.00016.09
5.6.110.0310.00315.79
5.6.100.0290.00315.95
5.6.90.0250.01315.98
5.6.80.0180.01415.92
5.6.70.0210.00915.90
5.6.60.0260.00916.04
5.6.50.0410.02116.18
5.6.40.0300.03216.04
5.6.30.0170.01715.95
5.6.20.0190.01715.84
5.6.10.0320.00516.02
5.6.00.0280.00316.11
5.5.380.0260.01115.98
5.5.370.0210.01316.06
5.5.360.0190.01916.06
5.5.350.0260.00715.96
5.5.340.0210.01115.92
5.5.330.0250.01115.91
5.5.320.0230.00916.06
5.5.310.0280.00616.09
5.5.300.0240.01216.14
5.5.290.0270.00816.14
5.5.280.0190.01616.07
5.5.270.0230.01215.87
5.5.260.0250.00716.05
5.5.250.0330.00916.11
5.5.240.0220.01216.00
5.5.230.0190.01315.96
5.5.220.0360.00015.96
5.5.210.0790.02916.14
5.5.200.0160.01315.84
5.5.190.0370.02515.93
5.5.180.0220.00915.86
5.5.170.0280.01715.98
5.5.160.0230.00615.92
5.5.150.0130.01915.95
5.5.140.0170.01215.88
5.5.130.0270.02215.88
5.5.120.0180.00915.70
5.5.110.0240.00816.11
5.5.100.0190.01515.91
5.5.90.0200.01015.97
5.5.80.0180.01015.73
5.5.70.0240.00616.08
5.5.60.0210.01115.86
5.5.50.0210.02815.95
5.5.40.0260.00315.72
5.5.30.0230.00716.09
5.5.20.0200.01216.11
5.5.10.0190.01316.00
5.5.00.0210.00815.76
5.4.450.0250.00312.87
5.4.440.0260.00312.70
5.4.430.0120.01213.07
5.4.420.0170.00912.96
5.4.410.0160.01012.86
5.4.400.0210.00712.63
5.4.390.0140.01412.96
5.4.380.0180.00712.93
5.4.370.0510.02412.82
5.4.360.0220.00912.75
5.4.350.0220.00812.82
5.4.340.0150.01512.89
5.4.330.0180.01112.77
5.4.320.0180.00813.02
5.4.310.0170.00312.59
5.4.300.0230.00312.54
5.4.290.0200.00412.91
5.4.280.0130.01012.68
5.4.270.0000.01812.63
5.4.260.0070.01712.80
5.4.250.0180.00613.04
5.4.240.0140.00812.99
5.4.230.0180.00612.73
5.4.220.0210.00312.65
5.4.210.0120.01312.67
5.4.200.0170.00612.85
5.4.190.0160.01012.63
5.4.180.0180.00712.88
5.4.170.0240.00012.71
5.4.160.0200.00312.60
5.4.150.0160.00612.88
5.4.140.0160.00812.73
5.4.130.0210.00412.84
5.4.120.0230.00712.75
5.4.110.0150.01312.75
5.4.100.0130.01612.90
5.4.90.0190.00512.71
5.4.80.0180.00612.83
5.4.70.0180.00712.88
5.4.60.0160.00713.00
5.4.50.0210.00512.83
5.4.40.0190.00812.85
5.4.30.0160.01612.96
5.4.20.0170.01112.94
5.4.10.0190.01112.76
5.4.00.0150.01212.82
5.3.290.0140.01413.36
5.3.280.0150.00913.39
5.3.270.0140.01113.41
5.3.260.0170.00913.27
5.3.250.0130.01313.24
5.3.240.0170.01313.16
5.3.230.0160.00813.33
5.3.220.0210.00613.05
5.3.210.0150.01213.03
5.3.200.0340.02713.16
5.3.190.0190.01013.08
5.3.180.0140.01013.36
5.3.170.0170.01013.21
5.3.160.0230.00413.50
5.3.150.0160.01313.39
5.3.140.0160.01413.19
5.3.130.0210.01113.43
5.3.120.0130.01713.32
5.3.110.0220.00613.20
5.3.100.0180.00713.14
5.3.90.0210.00713.09
5.3.80.0200.00813.02
5.3.70.0190.01313.03
5.3.60.0220.00513.34
5.3.50.0130.01613.17
5.3.40.0210.01013.23
5.3.30.0150.01113.37
5.3.20.0170.01213.39
5.3.10.0220.00613.04
5.3.00.0240.00712.99
5.2.170.0150.00712.41
5.2.160.0210.00312.41
5.2.150.0100.01112.32
5.2.140.0140.00712.24
5.2.130.0070.01412.16
5.2.120.0150.00512.11
5.2.110.0160.00712.23
5.2.100.0260.02912.04
5.2.90.0140.01112.02
5.2.80.0160.00812.11
5.2.70.0100.01512.15
5.2.60.0120.01011.96
5.2.50.0130.01312.00
5.2.40.0150.00912.20
5.2.30.0130.01011.95
5.2.20.0120.01211.87
5.2.10.0100.01012.16
5.2.00.0160.00611.63
5.1.60.0190.00010.77
5.1.50.0090.01310.85
5.1.40.0170.00410.84
5.1.30.0140.00710.97
5.1.20.0140.00710.98
5.1.10.0140.01110.93
5.1.00.0190.00010.69
5.0.50.0120.00610.02
5.0.40.0110.00410.01
5.0.30.0060.0099.85
5.0.20.0120.0089.83
5.0.10.0130.0069.69
5.0.00.0110.0079.89
4.4.90.0090.0029.20
4.4.80.0110.0039.20
4.4.70.0100.0009.20
4.4.60.0000.0129.20
4.4.50.0100.0029.20
4.4.40.0060.0069.20
4.4.30.0000.0129.20
4.4.20.0100.0039.20
4.4.10.0120.0009.20
4.4.00.0070.0049.20
4.3.110.0060.0039.20
4.3.100.0090.0009.20
4.3.90.0070.0049.20
4.3.80.0100.0029.20
4.3.70.0090.0039.20
4.3.60.0050.0079.20
4.3.50.0050.0059.20
4.3.40.0070.0059.20
4.3.30.0060.0039.20
4.3.20.0060.0039.20
4.3.10.0100.0009.20
4.3.00.0080.0039.20

preferences:
78.39 ms | 401 KiB | 5 Q