Page 1 of 1

Timer in PHP

Posted: Thu Jul 21, 2011 1:28 pm
by Sagar_999
Hey!!! I am making a project of Online Examination System, there I want to put a timer for exam.

Suppose no. of questions are 20 then Time would be 20 minutes (1 Question= 1 Minute)

How can I make it???

Re: Timer in PHP

Posted: Thu Jul 21, 2011 3:23 pm
by McInfo
A "timer" in PHP works like a time card system. First, the start time is recorded somewhere. Later, the stop time is recorded. The duration is found by subtracting the start time from the stop time. The only way to know whether the time has expired is to check the duration.

The client has no way of knowing how much time is left other than by watching a local clock. That is where JavaScript (or other client-side language) comes in. JavaScript can periodically display an updated time and perform other actions when the time has expired or is close to expiring.