Jump to content
php.lv forumi

countdown?


tiy

Recommended Posts

Vai var php mainigo padot javascriptam, piemeram $time="23:00:00";

 

countdown izvada ar javascriptu ka lidz 23:00 ir paliksuhasi

 

tagad ir piem. 16:00 izvada 8:00:00, tad 7:59:59 7:59:58 utt ?

 

te es atradu tikai tadu, kas parasti laiku skaita

 

<script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('time').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10) 
 {i="0" + i}
 return i
}
</script>


<body onload="startTime()">
<div  id="time"></div>

Edited by tiy
Link to comment
Share on other sites

-- <span  id="txt">_</span> --
<script> 
<!-- 

var sec=10
var min=0
var h=0

function display()
{ 


sec-=1 
if (sec<=0)
  {
	sec=59
	min-=1  
	 if (min<=0)
		 {
	min=59
			h-=1
		 }
  }	


if ( h==0 && min==0 && sec==0)
 {
  document.write("Hello World!") // nafig shitais nenostrada 
  h=0
  min=0
  sec=0
 } 

sec=checkTime(sec) 

if(min<10)
  document.getElementById('txt').innerHTML=h+":0"+min+":"+sec
else
  document.getElementById('txt').innerHTML=h+":"+min+":"+sec

 setTimeout("display()",500) 

function checkTime(i)
{
if (i<10) 
 {i="0" + i}
 return i
}

} 
display() 
--> 
</script>

 

bet kamer skaita rodas pie min nulles, bet pie sekundem viss ok

Edited by tiy
Link to comment
Share on other sites

×
×
  • Create New...