Last active
March 30, 2023 17:34
-
-
Save visb/ffaa76d7377a22a4b062 to your computer and use it in GitHub Desktop.
Somar horas com php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sumHours($firstHour, $secondHour) { | |
$baseDate = date('Y-m-d'); | |
$baseTime = strtotime($baseDate . ' 00:00:00'); | |
$firstTime = strtotime($baseDate . ' ' . $firstHour) - $baseTime; | |
$secondTime = strtotime($baseDate . ' ' . $secondHour) - $baseTime; | |
$resultTime = $firstTime + $secondTime; | |
return date('H:i:s', $baseTime + $resultTime); | |
} | |
echo sumHours('00:01:00', '00:00:50'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment