3v4l.org

run code in 300+ PHP versions simultaneously
<?php const SECONDS_PER_MINUTE = 60; const SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE; const SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR; const DAYS_PER_YEAR = 365; const DAYS_PER_LEAP_YEAR = DAYS_PER_YEAR + 1; const EPOCH_MONTH = 1; const EPOCH_YEAR = 1970; function getDateTime(int $timestamp) : array { $days = intdiv($timestamp, SECONDS_PER_DAY); $year = EPOCH_YEAR; while ($days >= getDaysForYear($year)) { $days -= getDaysForYear($year); $year++; } $daysPerMonth = getDaysPerMonth($year); $month = EPOCH_MONTH; while ($days >= $daysPerMonth[$month]) { $days -= $daysPerMonth[$month]; $month++; } $day = $days + 1; $secondsRemaining = $timestamp % SECONDS_PER_DAY; $hour = intdiv($secondsRemaining, SECONDS_PER_HOUR); $minute = intdiv($secondsRemaining, SECONDS_PER_MINUTE) % SECONDS_PER_MINUTE; $second = $secondsRemaining % SECONDS_PER_MINUTE; return [ 'year' => $year, 'month' => $month, 'day' => $day, 'hour' => $hour, 'minute' => $minute, 'second' => $second ]; } function isLeapYear(int $year) : bool { return $year % 400 === 0 || ($year % 4 === 0 && $year % 100 !== 0); } function getDaysForYear(int $year) : int { return isLeapYear($year) ? DAYS_PER_LEAP_YEAR : DAYS_PER_YEAR; } function getDaysPerMonth(int $year) : array { return [0, 31, isLeapYear($year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; } $time = 1471488076; //08/18/2016 @ 2:41am (UTC) print_r(getDateTime($time));

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.5.10.0090.00820.16
8.5.00.0150.00920.19
8.4.160.0160.01223.94
8.4.150.0090.00317.67
8.4.140.0230.01317.64
8.4.130.0130.00617.57
8.4.120.0150.00724.09
8.4.110.0090.01220.61
8.4.100.0140.00718.69
8.4.90.0130.00818.75
8.4.80.0070.00517.77
8.4.70.0120.00417.79
8.4.60.0130.00818.80
8.4.50.0120.00519.59
8.4.40.0130.00321.24
8.4.30.0060.01317.57
8.4.20.0100.00717.57
8.4.10.0060.00319.64
8.3.280.0060.00616.23
8.3.270.0110.00816.66
8.3.260.0100.01016.63
8.3.250.0130.00617.11
8.3.240.0060.00217.28
8.3.230.0120.00616.53
8.3.220.0120.00717.31
8.3.210.0040.00316.60
8.3.200.0030.00516.43
8.3.190.0070.00717.26
8.3.180.0110.00916.53
8.3.170.0080.00019.18
8.3.160.0060.00918.47
8.3.150.0060.01220.73
8.3.140.0090.00016.81
8.3.130.0080.00018.97
8.3.120.0060.00319.00
8.3.110.0030.00620.94
8.3.100.0040.00424.06
8.3.90.0050.00326.77
8.3.80.0060.00317.97
8.3.70.0140.00716.75
8.3.60.0340.00521.34
8.3.50.0180.00523.27
8.3.40.0240.00622.34
8.3.30.0220.00822.29
8.3.20.0180.01022.55
8.3.10.0210.00523.87
8.3.00.0210.00523.22
8.2.290.0030.00620.49
8.2.280.0130.00918.36
8.2.270.0070.00317.25
8.2.260.0040.00416.73
8.2.250.0080.00018.27
8.2.240.0080.00818.79
8.2.230.0000.00822.58
8.2.220.0050.00537.54
8.2.210.0000.00726.77
8.2.200.0060.00318.29
8.2.190.0120.00316.63
8.2.180.0230.00722.17
8.2.170.0240.00824.44
8.2.160.0250.00823.49
8.2.150.0280.00625.05
8.2.140.0240.00625.29
8.2.130.0240.00523.99
8.2.120.0220.00826.14
8.2.110.0250.00423.22
8.2.100.0200.00421.84
8.2.90.0160.00621.91
8.2.80.0170.00721.97
8.2.70.0150.00921.98
8.2.60.0200.00621.92
8.2.50.0140.00922.01
8.2.40.0200.00324.15
8.2.30.0150.00722.65
8.2.20.0160.00921.87
8.2.10.0150.00721.99
8.2.00.0180.00722.03
8.1.330.0100.00821.96
8.1.320.0100.00516.02
8.1.310.0090.00916.87
8.1.300.0060.00317.92
8.1.290.0060.00330.84
8.1.280.0200.00825.92
8.1.270.0220.00824.88
8.1.260.0240.00827.00
8.1.250.0250.00327.00
8.1.240.0210.00523.47
8.1.230.0180.00923.42
8.1.220.0220.00521.83
8.1.210.0200.00822.46
8.1.200.0190.01021.70
8.1.190.0190.00621.63
8.1.180.0170.01022.01
8.1.170.0150.00722.23
8.1.160.0150.00723.99
8.1.150.0160.00922.40
8.1.140.0180.00822.71
8.1.130.0190.00321.84
8.1.120.0150.01321.74
8.1.110.0170.00921.70
8.1.100.0200.00821.69
8.1.90.0200.00621.69
8.1.80.0220.00421.73
8.1.70.0150.00921.74
8.1.60.0160.00621.72
8.1.50.0130.00821.66
8.1.40.0150.00521.78
8.1.30.0130.00821.74
8.1.20.0100.01121.83
8.1.10.0180.00421.81
8.1.00.0140.00621.69
8.0.300.0120.00722.85
8.0.290.0220.00421.40
8.0.280.0170.00522.24
8.0.270.0230.00621.62
8.0.260.0180.00521.57
8.0.250.0160.00821.46
8.0.240.0170.01321.41
8.0.230.0180.00521.43
8.0.220.0230.00421.45
8.0.210.0160.00821.43
8.0.200.0150.00821.46
8.0.190.0170.00521.46
8.0.180.0160.00721.41
8.0.170.0140.00821.39
8.0.160.0210.00421.47
8.0.150.0210.01021.38
8.0.140.0160.00721.37
8.0.130.0180.00319.67
8.0.120.0210.00421.41
8.0.110.0150.00721.45
8.0.100.0160.00621.37
8.0.90.0240.00021.38
8.0.80.0180.01121.42
8.0.70.0210.00521.38
8.0.60.0180.01221.47
8.0.50.0170.00721.37
8.0.30.0130.01220.04
8.0.20.0160.00819.53
8.0.10.0180.01121.66
8.0.00.0140.00920.01
7.4.330.0150.00420.50
7.4.320.0160.00721.28
7.4.300.0150.00521.17
7.4.290.0150.00321.24
7.4.280.0130.00621.21
7.4.270.0160.00321.25
7.4.260.0160.00621.30
7.4.250.0140.00421.28
7.4.240.0160.00521.24
7.4.230.0160.00221.29
7.4.220.0200.00921.31
7.4.210.0180.00821.33
7.4.200.0210.00321.29
7.4.190.0430.00025.92
7.4.180.0350.00425.92
7.4.160.0150.00719.79
7.4.150.0130.01120.24
7.4.140.0160.00619.76
7.4.130.0150.00719.06
7.4.120.0100.01119.15
7.4.110.0150.01119.95
7.4.100.0130.00919.96
7.4.90.0190.00819.94
7.4.80.0120.01320.91
7.4.70.0150.00719.94
7.4.60.0120.01119.93
7.4.50.0190.00319.94
7.4.40.0140.01419.95
7.4.30.0140.01019.97
7.4.20.0210.00621.66
7.4.10.0190.00719.53
7.4.00.0180.00418.23
7.3.330.0220.00219.67
7.3.320.0240.00219.65
7.3.310.0230.00221.13
7.3.300.0150.00721.09
7.3.290.0100.01218.80
7.3.280.0100.00917.99
7.3.270.0120.00920.24
7.3.260.0140.00819.08
7.3.250.0120.00918.57
7.3.240.0110.01119.18
7.3.230.0120.01219.95
7.3.220.0160.00921.66
7.3.210.0140.00819.89
7.3.200.0120.01019.99
7.3.190.0170.00719.94
7.3.180.0190.00519.98
7.3.170.0170.00819.95
7.3.160.0200.00519.90
7.3.150.0250.00621.66
7.3.140.0270.00421.66
7.3.130.0200.00919.29
7.3.120.0140.01118.27
7.3.110.0160.00818.27
7.3.100.0150.00618.20
7.3.90.0120.00618.31
7.3.80.0080.01118.40
7.3.70.0150.00318.35
7.3.60.0130.00618.30
7.3.50.0100.01118.12
7.3.40.0140.00618.25
7.3.30.0120.00718.28
7.3.20.0160.00819.21
7.3.10.0100.00918.71
7.3.00.0090.00818.59
7.2.340.0300.00321.66
7.2.330.0200.00620.06
7.2.320.0200.01020.03
7.2.310.0220.00420.05
7.2.300.0200.00719.97
7.2.290.0230.01019.98
7.2.280.0270.00621.66
7.2.270.0240.01121.66
7.2.260.0160.01219.52
7.2.250.0160.01119.54
7.2.240.0180.00518.33
7.2.230.0120.01218.37
7.2.220.0090.01218.39
7.2.210.0120.01118.34
7.2.200.0180.00718.28
7.2.190.0160.01218.30
7.2.180.0150.01118.36
7.2.170.0170.00918.35
7.2.160.0170.01018.35
7.2.150.0170.00719.33
7.2.140.0180.00819.24
7.2.130.0130.00918.74
7.2.120.0150.00718.81
7.2.110.0150.00918.83
7.2.100.0140.00818.83
7.2.90.0160.00818.81
7.2.80.0110.01318.91
7.2.70.0160.00818.82
7.2.60.0110.00918.49
7.2.50.0120.00918.92
7.2.40.0160.00518.81
7.2.30.0160.00718.77
7.2.20.0160.00818.77
7.2.10.0390.01118.84
7.2.00.0110.01118.95
7.1.330.0480.00618.76
7.1.320.0120.01018.77
7.1.310.0170.00618.75
7.1.300.0150.00718.82
7.1.290.0220.00718.74
7.1.280.0190.00318.75
7.1.270.0160.00818.68
7.1.260.0160.00818.64
7.1.250.0160.00418.15
7.1.240.0210.00619.72
7.1.230.0200.00819.63
7.1.220.0610.00919.68
7.1.210.0140.01119.65
7.1.200.0160.00618.74
7.1.190.0210.01019.67
7.1.180.0170.00819.65
7.1.170.0160.00719.74
7.1.160.0180.00719.65
7.1.150.0140.01019.73
7.1.140.0160.00819.73
7.1.130.0170.01119.77
7.1.120.0170.00919.71
7.1.110.0190.00519.71
7.1.100.0150.00819.32
7.1.90.0130.01019.72
7.1.80.0180.00919.70
7.1.70.0170.00619.15
7.1.60.0100.01119.76
7.1.50.0180.00819.07
7.1.40.0150.01219.74
7.1.30.0190.00619.71
7.1.20.0200.00619.70
7.1.10.0180.00619.64
7.1.00.0180.02220.35
7.0.330.0160.01019.47
7.0.320.0160.00819.60
7.0.310.0130.01019.59
7.0.300.0170.01019.66
7.0.290.0200.00519.65
7.0.280.0210.00519.59
7.0.270.0170.01019.50
7.0.260.0140.01419.63
7.0.250.0190.01119.48
7.0.240.0250.00519.60
7.0.230.0150.00919.52
7.0.220.0190.00719.52
7.0.210.0210.00719.61
7.0.200.0240.00518.34
7.0.190.0130.01419.50
7.0.180.0140.00819.60
7.0.170.0220.00819.60
7.0.160.0210.00619.60
7.0.150.0180.01019.53
7.0.140.0220.00319.48
7.0.130.0250.00919.63
7.0.120.0160.00919.57
7.0.110.0180.00419.59
7.0.100.0130.01919.72
7.0.90.0190.01320.16
7.0.80.0170.02220.09
7.0.70.0170.02420.09
7.0.60.0180.02620.13
7.0.50.0120.02319.74
7.0.40.0140.01719.24
7.0.30.0180.02419.20
7.0.20.0180.02219.24
7.0.10.0150.01719.14
7.0.00.0140.02819.22
5.6.400.0170.00619.13
5.6.390.0200.00419.09
5.6.380.0200.00419.20
5.6.370.0110.01119.19
5.6.360.0200.00819.21
5.6.350.0130.01119.09
5.6.340.0160.00719.24
5.6.330.0180.00719.16
5.6.320.0210.00819.20
5.6.310.0170.01119.14
5.6.300.0200.00419.11
5.6.290.0220.00419.22
5.6.280.0160.01119.07
5.6.270.0180.00819.17
5.6.260.0150.00819.17
5.6.250.0140.01919.50
5.6.240.0180.02219.56
5.6.230.0110.02219.52
5.6.220.0120.02719.60
5.6.210.0130.02619.53
5.6.200.0170.01619.64
5.6.190.0180.02319.63
5.6.180.0120.02019.62
5.6.170.0090.03219.59
5.6.160.0110.02719.60
5.6.150.0120.01619.60
5.6.140.0150.03119.64
5.6.130.0150.02419.62
5.6.120.0180.02319.62
5.6.110.0140.02719.65
5.6.100.0170.02419.63
5.6.90.0160.01619.57
5.6.80.0120.02619.46
5.6.70.0170.02119.45
5.6.60.0140.02519.46
5.6.50.0160.02119.41
5.6.40.0160.02119.39
5.6.30.0150.02619.52
5.6.20.0190.01519.37
5.6.10.0170.02419.42
5.6.00.0200.02019.48

preferences:
43.25 ms | 403 KiB | 5 Q