3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Tuvi { private $day; private $month; private $year; const CAN = ["Giáp", "Ất", "Bính", "Đinh", "Mậu", "Kỷ", "Canh", "Tân", "Nhâm", "Qúy"]; const CHI = ["Tí", "Sửu", "Dần", "Mão", "Thìn", "Tỵ", "Ngọ", "Mùi", "Thân", "Dậu", "Tuất", "Hợi"]; public function __construct(int $day, int $month, int $year) { $this->day = $day; $this->month = $month; $this->year = $year; } public function toLunarDate() : string { $can = 3; $chi = 9; $comparingDate = new self(1, 3, 1996); $diffDays = $this->diffDays($comparingDate); if ($this->isLessThan($comparingDate)) { $can = ($can - $diffDays % 10 + 10) % 10; $chi = ($chi - $diffDays % 12 + 12) % 12; } else if ($this->isGreaterThan($comparingDate)) { $can = ($can + $diffDays % 10) % 10; $chi = ($chi + $diffDays % 12) % 12; } return sprintf("%s %s", static::CAN[$can], static::CHI[$chi]); } public function diffDays(Tuvi $t) : int { return $this->toDateTime()->diff($t->toDateTime())->days; } public function isLessThan(Tuvi $t) : bool { return $this->toDateTime() < $t->toDateTime(); } public function equals(Tuvi $t) : bool { return $this->toDateTime() == $t->toDateTime(); } public function isGreaterThan(TuVi $t) : bool { return $this->toDateTime() > $t->toDateTime(); } public function toDateTime() : DateTime { return new DateTime("{$this->year}-{$this->month}-{$this->day}"); } } $x = new Tuvi(31, 1, 1988); $y = new Tuvi(31,12,1989); var_dump( $x->diffDays($y), $x->isLessThan($y), $y->isLessThan($x), $x->toLunarDate(), (new Tuvi(15,12,1990))->toLunarDate(), (new Tuvi(25,3,2000))->toLunarDate(), (new Tuvi(27,11,1995))->toLunarDate() );

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.30.0100.00817.43
8.5.20.0120.00618.65
8.5.10.0130.00418.60
8.5.00.0180.01020.29
8.4.180.0150.00819.78
8.4.170.0080.01323.90
8.4.160.0100.01022.94
8.4.150.0090.00416.99
8.4.140.0080.01417.92
8.4.130.0060.00517.90
8.4.120.0120.00922.36
8.4.110.0130.00822.42
8.4.100.0100.01122.38
8.4.90.0150.00618.98
8.4.80.0040.00519.61
8.4.70.0120.00918.33
8.4.60.0140.00718.66
8.4.50.0100.00918.94
8.4.40.0080.00818.03
8.4.30.0060.01318.95
8.4.20.0140.00717.93
8.4.10.0060.00319.85
8.3.300.0130.00820.71
8.3.290.0110.01020.82
8.3.280.0120.00818.81
8.3.270.0180.00616.89
8.3.260.0140.00516.88
8.3.250.0100.00919.20
8.3.240.0110.00817.04
8.3.230.0090.00616.88
8.3.220.0110.00817.24
8.3.210.0080.00717.03
8.3.200.0030.00516.85
8.3.190.0110.01017.04
8.3.180.0040.00416.63
8.3.170.0110.00718.79
8.3.160.0070.01120.01
8.3.150.0100.00716.71
8.3.140.0040.00419.07
8.3.130.0030.00618.44
8.3.120.0130.00319.23
8.3.110.0040.00416.86
8.3.100.0030.00616.98
8.3.90.0130.01026.77
8.3.80.0060.00316.75
8.3.70.0110.00718.55
8.3.60.0060.01218.64
8.3.50.0120.00524.66
8.3.40.0090.00619.10
8.3.30.0080.00818.96
8.3.20.0050.00324.18
8.3.10.0030.00624.66
8.3.00.0000.00726.16
8.2.300.0120.00918.19
8.2.290.0130.00520.50
8.2.280.0090.00919.98
8.2.270.0100.01018.86
8.2.260.0090.00618.53
8.2.250.0070.01017.25
8.2.240.0060.00318.41
8.2.230.0060.00320.94
8.2.220.0040.00424.06
8.2.210.0040.00426.77
8.2.200.0000.00917.00
8.2.190.0100.01016.88
8.2.180.0140.00725.92
8.2.170.0150.00019.21
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0040.00426.35
8.2.110.0050.00520.58
8.2.100.0080.00417.91
8.2.90.0080.00017.88
8.2.80.0040.00419.03
8.2.70.0060.00317.75
8.2.60.0040.00417.88
8.2.50.0080.00018.18
8.2.40.0030.00618.29
8.2.30.0060.00318.30
8.2.20.0000.00718.34
8.2.10.0000.00719.38
8.2.00.0000.00719.43
8.1.340.0110.00917.77
8.1.330.0130.00621.98
8.1.320.0130.00618.30
8.1.310.0060.00918.57
8.1.300.0080.00319.85
8.1.290.0060.00330.84
8.1.280.0110.00425.92
8.1.270.0040.00423.99
8.1.260.0040.00428.09
8.1.250.0050.00328.09
8.1.240.0000.01123.64
8.1.230.0060.00620.73
8.1.220.0090.00018.94
8.1.210.0030.00518.77
8.1.200.0090.00017.73
8.1.190.0040.00417.60
8.1.180.0030.00618.10
8.1.170.0040.00417.82
8.1.160.0030.00619.05
8.1.150.0000.00719.00
8.1.140.0000.00719.00
8.1.130.0070.00020.20
8.1.120.0040.00417.75
8.1.110.0040.00417.73
8.1.100.0080.00017.69
8.1.90.0040.00417.58
8.1.80.0080.00017.77
8.1.70.0000.00717.73
8.1.60.0000.00917.81
8.1.50.0030.00617.68
8.1.40.0000.00817.71
8.1.30.0000.00817.86
8.1.20.0080.00317.75
8.1.10.0030.00517.78
8.1.00.0030.00617.64
8.0.300.0000.00818.77
8.0.290.0040.00417.00
8.0.280.0000.00718.61
8.0.270.0070.00018.20
8.0.260.0030.00318.52
8.0.250.0000.00717.19
8.0.240.0040.00417.29
8.0.230.0000.00717.28
8.0.220.0080.00017.21
8.0.210.0080.00017.16
8.0.200.0030.00317.13
8.0.190.0080.00017.28
8.0.180.0040.00417.13
8.0.170.0080.00017.21
8.0.160.0050.00317.32
8.0.150.0000.00717.05
8.0.140.0080.00017.05
8.0.130.0060.00013.63
8.0.120.0000.00817.05
8.0.110.0030.00517.02
8.0.100.0040.00417.24
8.0.90.0040.00417.09
8.0.80.0080.00817.13
8.0.70.0000.00817.15
8.0.60.0050.00317.08
8.0.50.0000.00817.17
8.0.30.0120.00617.38
8.0.20.0090.01017.30
8.0.10.0060.00317.36
8.0.00.0090.00917.04
7.4.330.0050.00015.55
7.4.320.0040.00416.62
7.4.300.0070.00016.68
7.4.290.0000.00716.63
7.4.280.0070.00416.78
7.4.270.0000.00716.75
7.4.260.0060.00013.44
7.4.250.0070.00016.65
7.4.240.0040.00416.64
7.4.230.0040.00416.78
7.4.220.0000.00716.63
7.4.210.0030.01316.75
7.4.200.0040.00316.66
7.4.130.0090.01116.68
7.4.120.0130.00916.61
7.4.110.0080.00816.57
7.4.100.0060.01616.78
7.4.90.0070.01016.59
7.4.80.0040.01319.39
7.4.70.0130.01116.62
7.4.60.0170.00616.67
7.4.50.0140.00716.61
7.4.40.0120.01216.43
7.4.30.0050.01616.58
7.4.20.0160.00916.67
7.4.10.0090.01316.66
7.4.00.0110.01016.60
7.3.330.0030.00516.33
7.3.320.0030.00313.52
7.3.310.0000.00716.30
7.3.300.0070.00016.50
7.3.290.0110.00716.46
7.3.260.0100.01416.38
7.3.240.0110.01016.62
7.3.230.0030.01516.68
7.3.210.0090.00916.45
7.3.200.0100.00716.66
7.3.190.0120.01116.58
7.3.180.0180.00316.53
7.3.170.0130.01016.54
7.3.160.0130.01016.62
7.3.150.0130.00616.56
7.3.140.0120.00916.56
7.3.130.0170.00416.63
7.3.120.0100.00816.63
7.3.110.0120.00816.47
7.3.100.0090.01216.60
7.3.90.0120.00816.49
7.3.80.0150.00716.50
7.3.70.0090.01016.44
7.3.60.0110.00816.54
7.3.50.0120.00816.45
7.3.40.0090.01116.48
7.3.30.0110.00816.42
7.3.20.0120.00816.55
7.3.10.0160.00716.42
7.3.00.0090.01316.51
7.2.330.0140.00417.01
7.2.320.0070.01017.02
7.2.310.0110.01316.88
7.2.300.0130.00916.93
7.2.290.0080.01616.85
7.2.280.0100.01316.66
7.2.270.0100.01216.79
7.2.260.0100.01216.95
7.2.250.0080.01216.77
7.2.240.0130.01016.83
7.2.230.0110.00916.77
7.2.220.0150.00916.67
7.2.210.0150.00616.85
7.2.200.0120.01016.64
7.2.190.0100.01016.66
7.2.180.0110.01016.69
7.2.170.0030.01716.72
7.2.160.0100.01016.71
7.2.150.0330.01016.71
7.2.140.0080.01616.70
7.2.130.0170.00816.77
7.2.120.0100.01216.83
7.2.110.0120.01016.68
7.2.100.0100.01216.75
7.2.90.0100.01316.78
7.2.80.0130.01116.68
7.2.70.0140.01516.75
7.2.60.0100.01216.65
7.2.50.0120.00916.69
7.2.40.0120.01016.63
7.2.30.0160.00716.81
7.2.20.0140.01216.70
7.2.10.0140.00816.67
7.2.00.0150.00616.86

preferences:
46.68 ms | 1500 KiB | 5 Q