DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

Calculate Average Time Duration in PHP from a csv file. Average time seems 0 milisseconds

Hello do you know how I can calculate an average time from a csv?

I have a csv file with these values:

Iteration, Duration
0,00:00:02.694414
81,00:00:02.790214
82,00:00:02.933225
83,00:00:03.077099
84,00:00:03.220184
85,00:00:03.363437

On the second column of it I have a time duration in H:i:s.ss format and I need to calculate the average duration: sum(Duration)/csv_size

In order to do that I use this function:

/**
 *

Top comments (0)