<? PHP
// The PHP time is calculated in seconds. The JS time is measured in milliseconds.
Date_default_timezone_set ('prc ');
// Date_default_timezone_set ("Asia/hong_kong"); // Region
// Configure the daily activity period
$ Starttimestr = "8:10:00 ";
$ Endtimestr = "9:43:00 ";
$ Starttime = strtotime ($ starttimestr );
$ Endtime = strtotime ($ endtimestr );
$ Nowtime = Time ();
If ($ nowtime <$ starttime ){
Die ("activity hasn't started yet. activity time: {$ starttimestr} to {$ endtimestr }");
}
If ($ endtime >=$ nowtime ){
$ Lefttime = $ endtime-$ nowtime; // The actual remaining time (seconds)
} Else {
$ Lefttime = 0;
Die ("the activity has ended! ");
}
?>
<Script language = "JavaScript">
VaR runtimes = 0;
Function getrtime (){
VaR NMS = <? PHP echo $ lefttime;?> * 1000-runtimes * 1000;
If (NmS> = 0 ){
VaR nD = math. Floor (NmS/(1000*60*60*24) % 24;
VaR nH = math. Floor (NmS/(1000*60*60) % 24;
VaR Nm = math. Floor (NmS/(1000*60) % 60;
VaR NS = math. Floor (NmS/1000) % 60;
Document. getelementbyid ("remaind"). innerhtml = Nd;
Document. getelementbyid ("remainh"). innerhtml = nH;
Document. getelementbyid ("remainm"). innerhtml = Nm;
Document. getelementbyid ("remains"). innerhtml = ns;
If (NMS = 5*60*1000)
{
Alert ("last five minutes! ");
}
Runtimes ++;
Settime out ("getrtime ()", 1000 );
}
}
VaR num = 0;
Onload = function (){
Refresh ();
Setinterval ("Refresh ();", 100 );
Getrtime ();
}
Function refresh (){
If (Num <10 ){
Document. getelementbyid ("remainl"). innerhtml = num;
Num = num + 1;
} Else {
Num = 0;
}
}
</SCRIPT>
<H4> <strong id = "remaind"> XX </strong> days <strong id = "remainh"> XX </strong> hours <strong id =" remainm "> XX </strong> minutes <strong id =" remains "> XX </strong>. <strong id = "remainl"> XX </strong> seconds </H4>