How to get time elapsed since a specific date time in PHP

1 Answer

0 votes
$startDateTime = new DateTime('2021-08-16 11:30:14');

$now = new DateTime();

$interval = $now->diff($startDateTime);

echo $interval->format('%y years %m months %d days %h hours %i minutes %s seconds');
  
  
  
  
/*
run:
  
2 years 3 months 24 days 23 hours 29 minutes 8 seconds
  
*/

 



answered Dec 10, 2023 by avibootz
...