Mysql
 sql >> Base de données >  >> RDS >> Mysql

comment calculer le temps passé sur mon application par horodatage

Vous pouvez calculer cela en utilisant la fonction timeDiff :

times = array();

foreach ($result as $row){
    // convert to unix timestamps
    $firstTime=strtotime($firstTime);
    $lastTime=strtotime($lastTime);

    // perform subtraction to get the difference (in seconds) between times
    $timeDiff=$lastTime-$firstTime;
    $times[] = $timeDiff;
    echo(secondsToTime($timeDiff));
    # 18 days, 23 hours, 41 minutes and 7 seconds
}

echo(secondsToTime(array_sum($times)));
#total of all times