hai, I want to create a timer for online test page which gets the time duration for countdown from database and dosenot reset on page refresh.
i have a timer which gets time from database but it resets on page refresh.
i am using php mysql.
i am a newbee so pls help me.
thanks in advance.
06-30-2012, 06:33 AM
007Julien
It easy to get a date with javascript from PHP like this
Code:
<?php
// Convert the timeLimit (coming from data base) to UTC
$timeLimit=mktime(0,0,0,1,1,2013);
?>
<script type="text/javascript">
// Define a javascript interger*1000 for seconds=>milliseconds
var timeLimit=parseInt("<?php echo $timeLimit ?>");
var dateLimit=new Date(timeLimit*1000);
//... Display a countDown with this date
</script