3v4l.org

run code in 300+ PHP versions simultaneously
<?php function weekCounter($startDate,$endDate=null){ //use today as endDate if no date was supplied $endDate = $endDate? : date('Y-m-d'); //calculate # of full weeks between dates $secsPerWeek = 60 * 60 * 24 * 7; $fullWeeks = floor((strtotime($endDate) - strtotime($startDate))/$secsPerWeek); $fullMonths = floor($fullWeeks/4); $weeksRemainder = $fullWeeks % 4; // weeks that don't fit in a month //increment from 0-base to 1-base, so first week is Week 1. Same with months $fullMonths++; $weeksRemainder++; return [$fullMonths,$weeksRemainder]; } $startDate = '2016-06-27'; //put function results in $months and $weeks variables list($months,$weeks) = weekCounter($startDate); //you can use the variables however you want echo "Month: $months, Week: $weeks";

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.130.0090.00018.64
8.3.120.0030.00620.68
8.3.110.0080.00020.94
8.3.100.0060.00324.06
8.3.90.0000.00826.77
8.3.80.0030.00617.97
8.3.70.0120.00316.75
8.3.60.0130.00316.88
8.3.50.0150.00523.00
8.3.40.0070.01419.04
8.3.30.0190.00418.88
8.3.20.0030.00722.03
8.3.10.0070.00021.91
8.3.00.0080.00019.91
8.2.250.0050.00516.91
8.2.240.0140.00317.37
8.2.230.0060.00322.58
8.2.220.0080.00037.54
8.2.210.0040.01426.77
8.2.200.0060.00316.50
8.2.190.0030.01318.45
8.2.180.0110.00416.75
8.2.170.0040.01122.96
8.2.160.0110.00722.27
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.00
8.2.110.0030.00721.12
8.2.100.0040.00818.34
8.2.90.0000.00819.52
8.2.80.0000.00817.97
8.2.70.0060.00317.74
8.2.60.0000.00818.16
8.2.50.0080.00018.10
8.2.40.0000.00822.16
8.2.30.0080.00419.40
8.2.20.0080.00017.98
8.2.10.0030.00518.12
8.2.00.0000.00818.13
8.1.300.0060.00317.78
8.1.290.0060.00330.84
8.1.280.0140.00325.92
8.1.270.0080.00023.95
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0030.00622.64
8.1.230.0120.00020.88
8.1.220.0050.00317.77
8.1.210.0030.00518.77
8.1.200.0030.00617.48
8.1.190.0040.00417.60
8.1.180.0030.00618.10
8.1.170.0000.00818.74
8.1.160.0100.00022.13
8.1.150.0070.00021.07
8.1.140.0000.00719.70
8.1.130.0000.00717.68
8.1.120.0040.00417.72
8.1.110.0040.00417.57
8.1.100.0070.00017.59
8.1.90.0040.00417.72
8.1.80.0070.00017.72
8.1.70.0000.00717.62
8.1.60.0000.00717.77
8.1.50.0030.00617.59
8.1.40.0000.00817.69
8.1.30.0040.00417.85
8.1.20.0080.00017.73
8.1.10.0000.00817.64
8.1.00.0040.00417.75
8.0.300.0040.00418.77
8.0.290.0000.00817.00
8.0.280.0000.00718.58
8.0.270.0070.00017.39
8.0.260.0000.00617.39
8.0.250.0080.00017.20
8.0.240.0000.00717.15
8.0.230.0050.00217.18
8.0.220.0040.00417.16
8.0.210.0030.00317.04
8.0.200.0000.00817.20
8.0.190.0050.00317.21
8.0.180.0040.00417.13
8.0.170.0080.00017.15
8.0.160.0000.00717.12
8.0.150.0040.00417.07
8.0.140.0030.00617.13
8.0.130.0000.00513.51
8.0.120.0040.00417.11
8.0.110.0080.00017.16
8.0.100.0000.00717.08
8.0.90.0040.00417.00
8.0.80.0060.00917.21
8.0.70.0040.00417.14
8.0.60.0000.00717.11
8.0.50.0070.00017.13
8.0.30.0110.00817.23
8.0.20.0090.00917.34
8.0.10.0040.01817.14
8.0.00.0070.01217.04
7.4.330.0000.00515.13
7.4.320.0040.00416.79
7.4.300.0030.00316.65
7.4.290.0000.00716.75
7.4.280.0040.00416.78
7.4.270.0030.00616.71
7.4.260.0040.00416.60
7.4.250.0040.00416.65
7.4.240.0030.00316.79
7.4.230.0060.00316.61
7.4.220.0050.00216.73
7.4.210.0040.01816.70
7.4.200.0030.00416.50
7.4.160.0020.01316.80
7.4.150.0090.00916.96
7.4.140.0110.00617.44
7.4.130.0120.00716.79
7.4.120.0090.01016.76
7.4.110.0060.01316.63
7.4.100.0100.00616.65
7.4.90.0060.01316.73
7.4.80.0110.01017.98
7.4.70.0090.00916.76
7.4.60.0140.00616.59
7.4.50.0140.00516.52
7.4.40.0110.00516.54
7.4.30.0030.01516.73
7.4.20.0060.00916.62
7.4.10.0070.01216.52
7.4.00.0120.00716.18
7.3.330.0030.00313.59
7.3.320.0030.00213.58
7.3.310.0000.00916.53
7.3.300.0000.00616.45
7.3.290.0080.01016.53
7.3.280.0050.01016.55
7.3.270.0120.00516.92
7.3.260.0070.01316.66
7.3.250.0080.01116.70
7.3.240.0100.00716.68
7.3.230.0080.01016.47
7.3.220.0100.01116.47
7.3.210.0090.00916.63
7.3.200.0100.00916.65
7.3.190.0110.00816.70
7.3.180.0140.00516.69
7.3.170.0100.01016.56
7.3.160.0060.01316.47
7.3.150.0120.00316.50
7.3.140.0090.00916.46
7.3.130.0100.01116.59
7.3.120.0090.01116.54
7.3.110.0130.00616.54
7.3.100.0090.01016.55
7.3.90.0080.01016.61
7.3.80.0070.01216.46
7.3.70.0120.00716.58
7.3.60.0050.01216.58
7.3.50.0090.00816.53
7.3.40.0090.01016.53
7.3.30.0100.00916.56
7.3.20.0210.00716.68
7.3.10.0190.00916.69
7.3.00.0160.00816.71
7.2.340.0070.01316.61
7.2.330.0100.01016.88
7.2.320.0090.01016.86
7.2.310.0110.00816.83
7.2.300.0070.01016.87
7.2.290.0100.00616.77
7.2.280.0120.00416.67
7.2.270.0070.01416.66
7.2.260.0080.01616.75
7.2.250.0090.01116.77
7.2.240.0120.01016.83
7.2.230.0050.01516.76
7.2.220.0090.01116.75
7.2.210.0120.00816.86
7.2.200.0090.01216.81
7.2.190.0120.00716.73
7.2.180.0100.01116.84
7.2.170.0120.00916.80
7.2.160.0130.00916.77
7.2.150.0620.00916.89
7.2.140.0160.01116.82
7.2.130.0200.01016.91
7.2.120.0190.01216.81
7.2.110.0310.00916.85
7.2.100.0160.01216.84
7.2.90.0200.00716.78
7.2.80.0190.00816.85
7.2.70.0180.01016.80
7.2.60.0150.00816.88
7.2.50.0160.00816.89
7.2.40.0200.01116.82
7.2.30.0180.01016.93
7.2.20.0200.00816.89
7.2.10.0160.01016.89
7.2.00.0180.00816.96
7.1.330.0120.01115.78
7.1.320.0200.00515.76
7.1.310.0100.01415.90
7.1.300.0190.00915.72
7.1.290.0170.01015.77
7.1.280.0210.00915.82
7.1.270.0190.00915.79
7.1.260.0210.00615.82
7.1.250.0270.00815.40
7.1.240.0360.00915.33
7.1.230.0300.00915.32
7.1.220.0260.01215.32
7.1.210.0230.01015.30
7.1.200.0200.01115.36
7.1.190.0300.01115.37
7.1.180.0260.01115.45
7.1.170.0300.01115.32
7.1.160.0240.01015.36
7.1.150.0310.00815.39
7.1.140.0260.00915.37
7.1.130.0600.01015.21
7.1.120.0290.00715.30
7.1.110.0270.00815.20
7.1.100.0300.00715.41
7.1.90.0270.00915.35
7.1.80.0270.01015.38
7.1.70.0220.00715.69
7.1.60.0230.00716.29
7.1.50.0280.00715.38
7.1.40.0240.00915.43
7.1.30.0310.00915.38
7.1.20.0230.01015.30
7.1.10.0310.00815.31
7.1.00.0240.02216.78
7.0.330.0300.01114.95
7.0.320.0240.01214.97
7.0.310.0370.00914.94
7.0.300.0260.00915.04
7.0.290.0280.00614.98
7.0.280.0250.00915.07
7.0.270.0300.01115.03
7.0.260.0430.01115.01
7.0.250.0230.01115.09
7.0.240.0270.00815.02
7.0.230.0230.00815.10
7.0.220.0280.00815.05
7.0.210.0250.00914.99
7.0.200.0240.00915.05
7.0.190.0250.00615.09
7.0.180.0300.00615.03
7.0.170.0300.00615.13
7.0.160.0200.01015.03
7.0.150.0250.01014.97
7.0.140.0270.00815.01
7.0.130.0290.01115.11
7.0.120.0280.01114.99
7.0.110.0280.00915.03
7.0.100.0400.00715.06
7.0.90.0290.01416.33
7.0.80.0280.02616.29
7.0.70.0200.02416.41
7.0.60.0270.02016.37
7.0.50.0240.02116.49
7.0.40.0260.02216.36
7.0.30.0230.02316.36
7.0.20.0260.01916.01
7.0.10.0190.02516.42
7.0.00.0230.01915.99
5.6.400.0210.01216.13
5.6.390.0210.00916.10
5.6.380.0220.00815.62
5.6.370.0150.01215.72
5.6.360.0120.01615.79
5.6.350.0190.00915.74
5.6.340.0160.01215.77
5.6.330.0180.00815.77
5.6.320.0160.01015.71
5.6.310.0150.00915.63
5.6.300.0160.01015.85
5.6.290.0160.01215.79
5.6.280.0140.00915.76
5.6.270.0150.01115.82
5.6.260.0150.01215.91
5.6.250.0190.00915.66
5.6.240.0150.02516.76
5.6.230.0120.02516.82
5.6.220.0140.02416.72
5.6.210.0160.01516.79
5.6.200.0170.01716.92
5.6.190.0080.02216.76
5.6.180.0150.02416.87
5.6.170.0140.02316.88
5.6.160.0090.02916.79
5.6.150.0130.02516.88
5.6.140.0170.02016.80
5.6.130.0110.02716.82
5.6.120.0150.01516.82
5.6.110.0170.02516.89
5.6.100.0150.02016.76
5.6.90.0140.02416.75
5.6.80.0150.01916.60
5.6.70.0150.01816.67
5.6.60.0160.02016.67
5.6.50.0130.02516.63
5.6.40.0120.02616.64
5.6.30.0180.02116.53
5.6.20.0140.01516.61
5.6.10.0130.02316.71
5.6.00.0140.02516.58
5.5.380.0090.01113.95
5.5.370.0100.01113.82
5.5.360.0120.01113.82
5.5.350.0080.01213.71
5.5.340.0100.01313.91
5.5.330.0180.00713.86
5.5.320.0110.00913.90
5.5.310.0160.00813.66
5.5.300.0140.00813.55
5.5.290.0100.01013.70
5.5.280.0170.00713.91
5.5.270.0110.01213.82
5.5.260.0140.00613.65
5.5.250.0120.00713.78
5.5.240.0170.00813.67
5.5.230.0130.01213.72
5.5.220.0190.00413.79
5.5.210.0180.01213.68
5.5.200.0180.00613.73
5.5.190.0130.00713.51
5.5.180.0180.00713.54
5.5.170.0120.01113.61
5.5.160.0140.00813.81
5.5.150.0140.01013.57
5.5.140.0180.00513.63
5.5.130.0150.00613.63
5.5.120.0130.00813.79
5.5.110.0160.00613.58
5.5.100.0140.00713.58
5.5.90.0110.01013.74
5.5.80.0120.00913.65
5.5.70.0150.00913.65
5.5.60.0130.01013.78
5.5.50.0170.00613.59
5.5.40.0100.01213.68
5.5.30.0150.00313.75
5.5.20.0170.00513.74
5.5.10.0110.01013.75
5.5.00.0100.00613.73
5.4.450.0110.00612.22
5.4.440.0120.00912.04
5.4.430.0130.00412.10
5.4.420.0090.00712.20
5.4.410.0130.00712.18
5.4.400.0180.01112.21
5.4.390.0110.00812.11
5.4.380.0130.00412.11
5.4.370.0160.00712.10
5.4.360.0090.00912.18
5.4.350.0110.01012.13
5.4.340.0060.00912.09
5.4.330.0180.00511.92
5.4.320.0080.01112.09
5.4.310.0120.00712.03
5.4.300.0150.00712.04
5.4.290.0120.00912.03
5.4.280.0140.00512.12
5.4.270.0120.01012.15
5.4.260.0190.00512.18
5.4.250.0180.00311.96
5.4.240.0150.00311.98
5.4.230.0170.00711.96
5.4.220.0130.00511.92
5.4.210.0110.00911.92
5.4.200.0140.00911.95
5.4.190.0130.00812.03
5.4.180.0180.00112.00
5.4.170.0060.00912.10
5.4.160.0150.00311.99
5.4.150.0140.00912.09
5.4.140.0110.00812.10
5.4.130.0130.00412.13
5.4.120.0090.00812.10
5.4.110.0130.00512.07
5.4.100.0110.00612.13
5.4.90.0110.00512.15
5.4.80.0100.00712.17
5.4.70.0110.00612.26
5.4.60.0140.00512.15
5.4.50.0120.00512.09
5.4.40.0100.00912.19
5.4.30.0070.00912.01
5.4.20.0100.00712.07
5.4.10.0110.00112.15
5.4.00.0130.00711.94
5.3.290.0090.00611.60
5.3.280.0100.00611.42
5.3.270.0060.00911.51
5.3.260.0150.00411.57
5.3.250.0120.00411.49
5.3.240.0120.00611.54
5.3.230.0090.00811.49
5.3.220.0080.01111.54
5.3.210.0100.00811.61
5.3.200.0050.01011.51
5.3.190.0120.00611.63
5.3.180.0040.00911.60
5.3.170.0120.00711.66
5.3.160.0070.01211.60
5.3.150.0070.00811.65
5.3.140.0060.01411.53
5.3.130.0090.00911.54
5.3.120.0120.00511.43
5.3.110.0170.00411.65
5.3.100.0110.00911.61
5.3.90.0100.01311.62
5.3.80.0100.01211.42
5.3.70.0150.00711.65
5.3.60.0110.00611.58
5.3.50.0110.00911.48
5.3.40.0100.00611.52
5.3.30.0110.01011.46
5.3.20.0110.01111.46
5.3.10.0120.00611.31
5.3.00.0120.00911.30
5.2.170.0090.00510.55
5.2.160.0110.00310.53
5.2.150.0070.00610.57
5.2.140.0100.00310.51
5.2.130.0120.00610.46
5.2.120.0110.00410.50
5.2.110.0080.00910.55
5.2.100.0130.00410.65
5.2.90.0140.00210.37
5.2.80.0090.00710.43
5.2.70.0130.00310.40
5.2.60.0080.00910.37
5.2.50.0090.00310.43
5.2.40.0080.00610.57
5.2.30.0040.00910.48
5.2.20.0060.00810.30
5.2.10.0120.00810.32
5.2.00.0050.00910.21
5.1.60.0090.0069.48
5.1.50.0080.0069.65
5.1.40.0070.0049.64
5.1.30.0070.0069.82
5.1.20.0070.0059.63
5.1.10.0120.0049.68
5.1.00.0060.0059.45
5.0.50.0080.0039.10
5.0.40.0050.0089.05
5.0.30.0060.0039.05
5.0.20.0070.0059.08
5.0.10.0100.0038.99
5.0.00.0100.0048.99
4.4.90.0050.0038.99
4.4.80.0040.0048.99
4.4.70.0020.0068.99
4.4.60.0040.0038.99
4.4.50.0070.0048.99
4.4.40.0080.0028.99
4.4.30.0040.0068.99
4.4.20.0070.0038.99
4.4.10.0040.0048.99
4.4.00.0070.0058.99
4.3.110.0020.0068.99
4.3.100.0060.0058.99
4.3.90.0050.0048.99
4.3.80.0050.0038.99
4.3.70.0050.0058.99
4.3.60.0030.0048.99
4.3.50.0040.0038.99
4.3.40.0030.0038.99
4.3.30.0020.0048.99
4.3.20.0040.0048.99
4.3.10.0050.0028.99
4.3.00.0040.0028.99

preferences:
29.7 ms | 403 KiB | 5 Q