At the beginning of the test, have PHP output a hidden form field with the time, e.g. <input type="hidden" name="starttime" value="<?= time(); ?>">
Then, when the form is submitted, subtract that time from the current time: $timelapsed = time() - $starttime;
Now $timeelapsed is, curiously enough, the time elapsed sinced the initial statement, in seconds, and you can play with that however you'd like. Of course, you'll need to factor in load times -- if the person sits at the computer for 15 seconds waiting for the next page to load, they shouldn't be penalized, should they?