3v4l.org

run code in 300+ PHP versions simultaneously
<?php $posts = array( array('post_id' => 7, 'timestamp' => '2014-04-20 20:17:49'), array('post_id' => 6, 'timestamp' => '2014-04-07 20:17:49'), array('post_id' => 5, 'timestamp' => '2014-03-17 20:17:49'), array('post_id' => 4, 'timestamp' => '2014-02-14 20:17:49'), array('post_id' => 3, 'timestamp' => '2014-01-09 20:17:49'), array('post_id' => 2, 'timestamp' => '2013-09-23 20:17:49'), array('post_id' => 1, 'timestamp' => '2012-09-23 20:17:49') ); $today = strtotime(date("Y-m-d")); $week_start = strtotime('last sunday', strtotime('tomorrow')); $month_start = strtotime(date_create(date("Y-m-d"))->modify('first day of this month')->format("Y-m-d")); $year_start = strtotime(date_create(date("Y-m-d"))->modify('first day of january 2014')->format("Y-m-d")); foreach ($posts as $post) { $item = strtotime($post['timestamp']); if ($item >= $today) { // Today echo '<br><br>' . 'Today' . '<br>'; echo $post['post_id'] . '<br>'; } else if (($item <= $today) && ($item >= $week_start)) { // This week echo '<br><br>' . 'This week' . '<br>'; echo $post['post_id'] . '<br>'; } else if (($item <= $week_start) && ($item >= $month_start)) { // This week echo '<br><br>' . 'This month' . '<br>'; echo $post['post_id'] . '<br>'; } else if (($item <= $month_start) && ($item >= $year_start)) { // This week echo '<br><br>' . 'This year' . '<br>'; echo $post['post_id'] . '<br>'; } }

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.00616.88
8.3.50.0220.00517.32
8.3.40.0160.00618.79
8.3.30.0110.00418.96
8.3.20.0060.00918.72
8.3.10.0050.00319.02
8.3.00.0030.00619.38
8.2.180.0110.00418.41
8.2.170.0070.01322.96
8.2.160.0070.00719.08
8.2.150.0000.00924.18
8.2.140.0000.00824.66
8.2.130.0050.00226.16
8.2.120.0070.00419.31
8.2.110.0060.00322.17
8.2.100.0060.00618.08
8.2.90.0000.00817.88
8.2.80.0060.00319.17
8.2.70.0090.00017.88
8.2.60.0000.00817.88
8.2.50.0030.00518.18
8.2.40.0000.00819.60
8.2.30.0100.00018.11
8.2.20.0000.00918.04
8.2.10.0040.00418.11
8.2.00.0050.00318.01
8.1.280.0060.00925.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0120.00619.67
8.1.230.0070.00420.89
8.1.220.0000.00818.89
8.1.210.0030.00518.77
8.1.200.0040.00417.48
8.1.190.0030.00517.38
8.1.180.0060.00318.10
8.1.170.0000.00817.62
8.1.160.0050.00219.13
8.1.150.0000.00718.82
8.1.140.0040.00417.70
8.1.130.0070.00017.61
8.1.120.0000.00817.66
8.1.110.0040.00417.79
8.1.100.0030.00617.65
8.1.90.0000.00717.80
8.1.80.0000.00717.78
8.1.70.0000.00717.68
8.1.60.0030.00617.84
8.1.50.0040.00417.72
8.1.40.0050.00317.72
8.1.30.0030.00617.89
8.1.20.0040.00417.88
8.1.10.0050.00217.85
8.1.00.0000.00817.68
8.0.300.0040.00418.77
8.0.290.0070.00017.13
8.0.280.0000.00718.82
8.0.270.0050.00317.49
8.0.260.0070.00017.14
8.0.250.0040.00417.14
8.0.240.0000.00717.31
8.0.230.0040.00417.30
8.0.220.0030.00317.20
8.0.210.0000.00717.21
8.0.200.0040.00417.27
8.0.190.0080.00017.18
8.0.180.0000.00917.20
8.0.170.0030.00517.16
8.0.160.0000.00817.20
8.0.150.0000.00917.20
8.0.140.0040.00417.20
8.0.130.0030.00313.54
8.0.120.0000.01017.16
8.0.110.0000.00817.17
8.0.100.0040.00417.25
8.0.90.0040.00416.98
8.0.80.0100.00717.17
8.0.70.0040.00417.07
8.0.60.0050.00317.05
8.0.50.0080.00017.08
8.0.30.0000.01517.52
8.0.20.0130.00517.20
8.0.10.0030.00517.20
8.0.00.0090.01217.02
7.4.330.0050.00013.27
7.4.320.0060.00016.75
7.4.300.0060.00016.83
7.4.290.0080.00016.64
7.4.280.0000.00716.89
7.4.270.0000.00816.85
7.4.260.0000.00513.44
7.4.250.0040.00416.71
7.4.240.0070.00016.79
7.4.230.0000.00816.48
7.4.220.0070.01116.68
7.4.210.0100.00616.70
7.4.200.0000.00816.82
7.4.190.0000.01016.82
7.4.160.0110.00616.84
7.4.150.0100.01616.86
7.4.140.0130.00617.86
7.4.130.0120.00916.86
7.4.120.0070.01016.76
7.4.110.0090.00916.85
7.4.100.0120.00916.82
7.4.90.0110.00716.60
7.4.80.0110.01419.39
7.4.70.0060.01016.77
7.4.60.0100.00716.80
7.4.50.0000.00616.70
7.4.40.0100.00316.86
7.4.30.0080.00816.54
7.4.10.0070.01214.98
7.4.00.0060.01115.15
7.3.330.0000.00613.38
7.3.320.0000.00513.34
7.3.310.0070.00016.39
7.3.300.0070.00016.58
7.3.290.0040.01216.52
7.3.280.0060.00916.46
7.3.270.0040.01416.67
7.3.260.0140.00316.48
7.3.240.0080.00816.73
7.3.230.0100.00716.78
7.3.210.0070.01016.57
7.3.200.0100.00716.70
7.3.190.0070.01716.71
7.3.180.0060.00916.76
7.3.170.0090.00916.61
7.3.160.0030.01416.87
7.3.130.0090.00915.29
7.3.120.0050.01515.08
7.3.110.0050.01415.13
7.3.100.0090.00514.90
7.3.90.0080.00715.17
7.3.80.0040.00715.03
7.3.70.0050.00814.92
7.3.60.0070.00815.03
7.3.50.0070.00915.19
7.3.40.0000.01315.17
7.3.30.0030.01314.93
7.3.20.0080.00616.92
7.3.10.0050.00816.81
7.3.00.0040.01016.93
7.2.330.0100.00716.74
7.2.320.0060.01116.75
7.2.310.0030.01316.67
7.2.300.0130.00917.12
7.2.290.0000.01716.74
7.2.260.0070.01215.42
7.2.250.0030.01415.42
7.2.240.0030.01115.39
7.2.230.0090.00615.33
7.2.220.0030.00915.24
7.2.210.0060.01015.28
7.2.200.0100.00615.42
7.2.190.0050.01115.26
7.2.180.0020.01415.21
7.2.170.0070.00915.16
7.2.160.0050.01015.13
7.2.150.0090.00317.02
7.2.140.0040.00917.20
7.2.130.0090.00617.20
7.2.120.0060.00617.20
7.2.110.0040.01017.08
7.2.100.0080.00817.25
7.2.90.0070.00817.06
7.2.80.0060.00717.18
7.2.70.0060.00817.27
7.2.60.0060.00916.97
7.2.50.0060.01017.23
7.2.40.0060.00917.18
7.2.30.0100.00417.16
7.2.20.0050.00717.10
7.2.10.0040.01117.17
7.2.00.0030.00917.80
7.1.330.0030.00916.03
7.1.320.0030.01016.10
7.1.310.0060.00615.96
7.1.300.0080.00415.83
7.1.290.0070.00415.99
7.1.280.0020.01115.99
7.1.270.0040.00915.94
7.1.260.0000.01515.93
7.1.250.0040.01115.98
7.1.240.0050.00816.08
7.1.230.0040.00816.03
7.1.220.0000.01415.95
7.1.210.0050.00815.88
7.1.200.0050.00816.04
7.1.190.0030.01216.05
7.1.180.0020.01115.87
7.1.170.0070.00615.99
7.1.160.0080.00316.00
7.1.150.0010.01316.07
7.1.140.0030.01015.97
7.1.130.0070.00716.02
7.1.120.0050.00915.96
7.1.110.0060.00415.98
7.1.100.0040.00716.59
7.1.90.0070.00615.93
7.1.80.0020.01016.05
7.1.70.0070.00516.35
7.1.60.0090.00416.33
7.1.50.0060.00916.32
7.1.40.0080.00916.00
7.1.30.0030.01216.04
7.1.20.0070.00615.91
7.1.10.0100.00415.95
7.1.00.0040.02517.43
7.0.330.0080.00515.53
7.0.320.0050.01015.64
7.0.310.0050.00915.62
7.0.300.0050.00815.62
7.0.290.0110.00115.54
7.0.280.0050.00815.48
7.0.270.0020.01015.70
7.0.260.0050.00515.43
7.0.250.0050.00815.50
7.0.240.0020.01015.55
7.0.230.0040.00815.51
7.0.220.0050.00615.55
7.0.210.0070.00715.61
7.0.200.0080.00615.89
7.0.190.0090.00415.47
7.0.180.0080.00515.52
7.0.170.0040.01115.50
7.0.160.0060.00815.54
7.0.150.0030.00915.51
7.0.140.0050.02617.27
7.0.130.0090.00715.61
7.0.120.0060.02317.12
7.0.110.0060.00615.62
7.0.100.0060.02616.56
7.0.90.0060.02316.69
7.0.80.0060.02516.69
7.0.70.0070.02616.70
7.0.60.0080.02416.66
7.0.50.0070.02616.81
7.0.40.0050.01515.28
7.0.30.0050.01815.17
7.0.20.0060.02415.22
7.0.10.0050.02715.27
7.0.00.0070.02015.16
5.6.400.0080.00814.52
5.6.390.0110.00514.66
5.6.380.0040.01014.65
5.6.370.0040.00914.57
5.6.360.0060.00814.59
5.6.350.0050.00814.65
5.6.340.0030.01014.59
5.6.330.0100.00314.54
5.6.320.0090.00614.61
5.6.310.0090.00514.50
5.6.300.0080.00814.60
5.6.290.0090.00614.53
5.6.280.0030.02716.15
5.6.270.0070.00614.58
5.6.260.0070.00714.60
5.6.250.0060.02716.19
5.6.240.0080.02616.20
5.6.230.0100.02416.20
5.6.220.0040.02716.02
5.6.210.0050.01916.07
5.6.200.0070.02616.13
5.6.190.0070.01616.26
5.6.180.0040.02816.06
5.6.170.0060.01616.03
5.6.160.0050.01616.14
5.6.150.0070.01516.04
5.6.140.0080.02316.20
5.6.130.0050.02716.20
5.6.120.0030.02016.05
5.6.110.0080.02016.21
5.6.100.0040.02716.20
5.6.90.0080.02516.04
5.6.80.0040.02015.95
5.6.70.0070.01915.96
5.6.60.0060.02515.88
5.6.50.0080.01716.16
5.6.40.0070.02215.91
5.6.30.0040.02515.97
5.6.20.0070.01715.93
5.6.10.0060.02515.90
5.6.00.0070.02516.01
5.5.380.0050.02615.12
5.5.370.0050.02515.16
5.5.360.0070.02315.22
5.5.350.0070.02115.20
5.5.340.0090.02115.15
5.5.330.0090.02315.29
5.5.320.0060.01615.32
5.5.310.0070.02215.15
5.5.300.0050.01715.30
5.5.290.0090.02415.32
5.5.280.0060.02315.34
5.5.270.0070.01615.25
5.5.260.0050.01715.32
5.5.250.0040.01715.17
5.5.240.0040.01915.06
5.5.230.0030.02715.02
5.5.220.0040.02315.07
5.5.210.0070.02414.99
5.5.200.0100.01815.15
5.5.190.0070.02515.01
5.5.180.0060.02314.97
5.5.170.0050.00713.34
5.5.160.0080.01915.04
5.5.150.0080.02215.07
5.5.140.0020.02615.06
5.5.130.0060.02515.02
5.5.120.0070.02415.08
5.5.110.0040.01814.88
5.5.100.0040.02515.13
5.5.90.0080.01915.04
5.5.80.0040.01914.99
5.5.70.0050.02514.83
5.5.60.0030.02614.91
5.5.50.0040.02515.08
5.5.40.0040.02615.08
5.5.30.0060.02415.01
5.5.20.0030.02215.04
5.5.10.0070.02115.10
5.5.00.0050.02614.96
5.4.450.0030.02613.62
5.4.440.0020.02713.63
5.4.430.0030.01713.67
5.4.420.0060.02413.67
5.4.410.0070.01813.66
5.4.400.0060.02013.45
5.4.390.0070.01313.55
5.4.380.0060.01913.47
5.4.370.0050.02413.46
5.4.360.0070.02313.54
5.4.350.0060.01413.39
5.4.340.0090.02013.34
5.4.330.0050.00611.68
5.4.320.0050.02413.57
5.4.310.0060.01513.38
5.4.300.0030.02413.54
5.4.290.0050.02413.58
5.4.280.0060.02413.47
5.4.270.0030.01713.47
5.4.260.0060.02213.51
5.4.250.0020.02313.44
5.4.240.0020.02813.50
5.4.230.0020.02413.59
5.4.220.0070.02213.53
5.4.210.0060.02213.35
5.4.200.0090.01713.46
5.4.190.0040.02413.38
5.4.180.0080.01713.49
5.4.170.0040.01713.47
5.4.160.0020.02113.47
5.4.150.0080.01913.40
5.4.140.0030.02212.77
5.4.130.0040.02312.77
5.4.120.0040.02512.85
5.4.110.0090.01412.81
5.4.100.0050.02212.91
5.4.90.0060.02212.87
5.4.80.0030.02112.84
5.4.70.0060.02212.81
5.4.60.0080.01912.89
5.4.50.0070.01712.94
5.4.40.0090.01912.73
5.4.30.0060.02112.79
5.4.20.0060.01612.79
5.4.10.0060.02212.86
5.4.00.0060.01712.67
5.3.290.0060.02512.26
5.3.280.0090.02012.16
5.3.270.0080.02212.18
5.3.260.0070.01812.28
5.3.250.0060.02012.17
5.3.240.0060.02512.14
5.3.230.0060.02412.14
5.3.220.0060.01812.09
5.3.210.0040.02412.14
5.3.200.0060.02112.12
5.3.190.0050.01612.13
5.3.180.0070.02212.14
5.3.170.0070.02312.17
5.3.160.0040.02612.15
5.3.150.0080.02212.17
5.3.140.0060.02412.16
5.3.130.0050.02512.12
5.3.120.0080.02212.08
5.3.110.0090.02012.12
5.3.100.0060.02311.98
5.3.90.0100.02012.02
5.3.80.0070.02211.98
5.3.70.0090.02111.94
5.3.60.0060.02411.93
5.3.50.0120.01912.02
5.3.40.0060.02512.04
5.3.30.0040.02312.02
5.3.20.0050.02211.85
5.3.10.0050.01311.81
5.3.00.0060.01811.76
5.2.170.0020.03910.49
5.2.160.0080.02710.61
5.2.150.0020.03710.59
5.2.140.0050.03310.44
5.2.130.0030.02510.33
5.2.120.0020.01910.46
5.2.110.0050.01810.45
5.2.100.0000.01910.48
5.2.90.0030.01910.43
5.2.80.0050.03210.30
5.2.70.0050.03210.36
5.2.60.0050.02810.42
5.2.50.0050.02210.47
5.2.40.0050.02510.38
5.2.30.0030.02610.29
5.2.20.0000.03410.36
5.2.10.0050.03310.31
5.2.00.0030.03310.27
5.1.60.0020.03010.04
5.1.50.0060.03010.04
5.1.40.0020.03210.09
5.1.30.0040.02810.09
5.1.20.0070.02810.04
5.1.10.0030.03010.08
5.1.00.0040.02410.04
5.0.50.0000.02710.04
5.0.40.0040.01410.04
5.0.30.0030.03110.04
5.0.20.0030.02410.04
5.0.10.0020.02310.04
5.0.00.0020.03510.04
4.4.90.0020.01710.04
4.4.80.0020.01310.04
4.4.70.0030.01810.04
4.4.60.0020.01510.04
4.4.50.0020.01910.04
4.4.40.0020.03010.04
4.4.30.0020.02010.04
4.4.20.0030.01810.04
4.4.10.0000.02410.04
4.4.00.0000.01710.04
4.3.110.0030.01810.04
4.3.100.0070.00610.04
4.3.90.0030.01710.04
4.3.80.0040.02910.04
4.3.70.0050.01810.04
4.3.60.0030.01510.04
4.3.50.0030.01810.04
4.3.40.0020.02710.04
4.3.30.0020.01710.04
4.3.20.0000.02210.04
4.3.10.0020.02010.04
4.3.00.0020.01810.04

preferences:
44.57 ms | 401 KiB | 5 Q