Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
PHP で時間文字列 (2:12:0 など) を 10 進数形式 (例: 2:12:0 は 2.2 時間) に変換したいと考えています。
コロンによる爆発を使用して、私の頭の上からかなりばかげた変換:
<?php $hms = "2:12:0"; $decimalHours = decimalHours($hms); function decimalHours($time) { $hms = explode(":", $time); return ($hms[0] + ($hms[1]/60) + ($hms[2]/3600)); } echo $decimalHours; ?>