PHP Online Compiler
Example: Difference Between Two Time Periods in PHP using strtotime
C
C++
C#
Java
Python
PHP
main.php
STDIN
Run
// DIFFERENCE BETWEEN TWO TIME PERIODS in PHP using strtotime <?php $time1 = strtotime("2025-05-01 10:30:00"); $time2 = strtotime("2025-05-09 15:45:00"); $diff = $time2 - $time1; $hours = floor($diff / 3600); $minutes = floor(($diff % 3600) / 60); $seconds = $diff % 60; echo "\nTIME DIFFERENCE: $hours HOURS, $minutes MINUTES, $seconds SECONDS\n"; ?>
Output
Clear
ADVERTISEMENTS