Timer in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sagar_999
Forum Newbie
Posts: 7
Joined: Tue Jun 28, 2011 11:36 pm

Timer in PHP

Post 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???
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Timer in PHP

Post 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.
Post Reply