Q:

How to format time to "H:i:s" in laravel using carbon

I would like to find total time spent on a project given that the user enters the "start time" and "stop time".  I have been able to access the time spent but it comes as an array of Date Interval.  
I want to just format the results to "H:i:s" (Hour:Minute:Seconds)
Here's the code from my controller
I have already declare the use of Carbon Class(use Carbon/Carbon;) at the top of the controller
    $start = Carbon::parse($request->strt_time);
    $end = Carbon::parse($request->stp_time);
    $time_spent = $end->diff($start);

    $spent_time = $time_spent->format('H:i:s');

I expect the output to be 00:00:00 but I am getting a string "H:i:s"

A:

diff() method gives CarbonInterval, which inherits the format function from DateInterval.  The documentation states that Each format character must be prefixed by a percent sign (%)
 DateInterval::format ( string $format ) : string

 $january = new DateTime('2010-01-01');
 $february = new DateTime('2010-02-01');
 $interval = $february->diff($january);

 // %a will output the total number of days. 
 echo $interval->format('%a total days')."\n";

 // While %d will only output the number of days not already covered by the
 // month. 
 echo $interval->format('%m month, %d days');

so final solution is
$end->diff($start)->format('%H:%i:%s');

