Timestamps
Moderator: General Moderators
Timestamps
I'm making an online test that checks to see how long it took someone to take that test. When they begin, a timestamp is created, once they finish, a new one is created. How can I take the two timestamps and echo that out to say how long it took them to take the test?
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
Re: Timestamps
Code: Select all
$start = date('Y-m-d H:i:s', time() - (5 * 60 * 60));
$end = date('Y-m-d H:i:s', time());
$startTime = new DateTime($start);
$endTime = new DateTime($end);
$diff = $endTime->diff($startTime);
echo $diff->format('%H:%I:%S');