View Full Version : how to set timer start with zero
01-10-2008, 10:58 AM
How to set timer with start and end time?
01-10-2008, 12:55 PM
You'll have to provide more information about your needs,
and also what the purpose of the timer will be.
01-10-2008, 01:10 PM
I am trying to build a clock in PHP that counts down start from 0:00:00 to 0:30:00, resets itself and starts over again.
Any idea how I can get that to work?
01-10-2008, 01:38 PM
I just had to do the same thing!
do you need an event to happen at the end of 30mins or do you simply just need the time to be displayed?
If you need an event to take place at then end of the minutes you can use a cronjob. All you do is write the script you want to happen every 30mins, & then set it up as a cron jon in you CPANEL crontab section.
01-10-2008, 02:20 PM
server-side scripting language. If all it has to do is count down, then reset,
01-10-2008, 02:22 PM
I am doing online examination site using PHP
If the user enter into the site and start to write the exam, I need to display the clock with start time as 00:00:00 and calculate the end time as 00:30:00 After the end time the test page will be redirected to the result page.
This is my requirement. Can anyone help me.
01-10-2008, 02:29 PM
Does your web host use cPanel as the interface and do they allow you to use cronJobs with your current plan? If you are not sure about these questions contact your host.
If the answer to these was yes I'll explain how to set up the php.
01-10-2008, 03:00 PM
This is the closest thing I could find.
It times-out and redirects to another page.
You didn't mention if they answer each question one at a time and the
page refreshes or not ... refreshing would reset the timer.
Or, do they stay on the page and click radio buttons without refreshing?
You'll need to use PHP session variables to keep track of time if they
refresh the page.
With that script above, and using PHP sessions, you could have a deal where
each question is automatically displayed when the timer reaches zero. If they
didn't answer it, too bad ... it would just jump to the next question.
If they answer it, you could log the time taken and then go to the next question.
It would allow you to see how long it takes the user to answer.
As you can see ... your project could get more complex, and more interesting.
01-11-2008, 07:03 AM
Yes. My page refreshes while writing the exam.i go through the link and applied it in my application. It works but it reset the timer as you said. Is there any other idea for my requirement. I dont have any idea regarding this. If my page do not refresh means, your script is good. I dont know how to write the exam without refreshing the pages.
01-11-2008, 05:06 PM
Here's my thought ... but I didn't have time to make any code examples (sorry).
The timer starts on the first page.
If they exit the page, either with a "submit" button, or browser button,
the current time gets saved in a cookie.
and continue counting.
.... and so on ....
the next page.
So you need this script on each page:
Then you'll need to check for the submit button to save the cookie.
I don't have an example of that part.
Sorry I can't be of more help ... I'm just too swamped today.
01-12-2008, 03:17 AM
You could also save the time they started in a php session that will be available on any refreshed pages, and calculate how much time they have left based on the current time (30 mins - (cur time - start time)). If you want the clock to actively count down while they are viewing the page, you can have php output the time they have left as part of a countdown script.
01-12-2008, 10:43 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.