3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class MySqlTime { public function __construct( public int $hours, public int $minutes, public int $seconds, ) { } public static function fromMySqlTimeAsDurationInDay(string $time): self { [$hours, $minutes, $seconds] = array_map('intval', explode(':', $time)); // Ensure only positive values on a single day. // MySql should already be throwing errors about minutes or seconds being out of range, so we don't // need to check those. // The seconds could include decimals, however for this purpose we are ignoring them. if ($hours > 23 || $hours < 0) { throw new InvalidArgumentException('Hours must be between 0 and 23'); } return new self($hours, $minutes, $seconds); } public function toDateTime(DateTimeInterface $dateTime = null) : DateTimeInterface { $dateTime ??= new DateTimeImmutable(); return $dateTime->setTime($this->hours, $this->minutes, $this->seconds); } } var_dump(MySqlTime::fromMySqlTimeAsDurationInDay('12:34:56')->toDateTime());

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.4.120.0130.00722.43
8.4.110.0050.00522.38
8.4.100.0110.01018.25
8.4.90.0090.00718.84
8.4.80.0060.00418.08
8.4.70.0140.00718.34
8.4.60.0120.00820.81
8.4.50.0170.00819.76
8.4.40.0070.01417.89
8.4.30.0100.01020.69
8.4.20.0160.00322.32
8.4.10.0030.00623.88
8.3.250.0110.00918.96
8.3.240.0050.00416.72
8.3.230.0030.00616.62
8.3.220.0170.00217.35
8.3.210.0080.01216.71
8.3.200.0050.00816.70
8.3.190.0130.00617.09
8.3.180.0090.01016.82
8.3.170.0070.01119.28
8.3.160.0090.00918.63
8.3.150.0100.01020.78
8.3.140.0090.00016.63
8.3.130.0030.00618.24
8.3.120.0080.00319.07
8.3.110.0000.00918.51
8.3.100.0030.00618.80
8.3.50.0110.00718.56
8.2.290.0050.00420.28
8.2.280.0100.00918.63
8.2.270.0140.00717.17
8.2.260.0050.00319.07
8.2.250.0040.00718.33
8.2.240.0120.00318.95
8.2.230.0000.00818.39
8.2.220.0040.00418.68
8.2.70.0050.00779.33
8.1.330.0090.00621.77
8.1.320.0140.00516.23
8.1.310.0080.00016.50
8.1.300.0080.00020.18

preferences:
26.29 ms | 403 KiB | 5 Q