I am using this to create a string with the difference between dates:
$startDate = DateTime::createFromFormat(self::$timeFormat, $startDate);
$difference = $startDate->diff($endDate);
$dateTimeElapsed = $difference->format('%y years %m months %a days %h hours %i minutes %S seconds');
return $dateTimeElapsed;
And that would output something like: 0 years 0 months 0 days 0 hours 0 minutes 27 seconds
How can I code it so I can remove any zero values such as 0 years, months etc...