導航:首頁 > 編程語言 > phpjs倒計時

phpjs倒計時

發布時間:2023-08-26 08:26:51

㈠ 用JavaScript或php怎麼寫一個倒計時時鍾啊

這個是JavaScript的
距離北京奧運會開幕還有
<br>
<html>
<head>
<title>倒計時測試</title>
<!--倒計時設置代碼-->
<script language="JavaScript">
<!-- hide script from old browser
var DifferenceHour = -1
var DifferenceMinute = -1
var DifferenceSecond = -1
var Tday = new Date("Aug 8, 2008 20:00:00") //**倒計時時間點-注意格式
var daysms = 24 * 60 * 60 * 1000
var hoursms = 60 * 60 * 1000
var Secondms = 60 * 1000
var microsecond = 1000
function clock()
{
var time = new Date()
var hour = time.getHours()
var minute = time.getMinutes()
var second = time.getSeconds()
var timevalue = ""+((hour > 12) ? hour-12:hour)
timevalue +=((minute < 10) ? ":0":":")+minute
timevalue +=((second < 10) ? ":0":":")+second
timevalue +=((hour >12 ) ? " PM":" AM")
// document.formnow.now.value = timevalue
var convertHour = DifferenceHour
var convertMinute = DifferenceMinute
var convertSecond = DifferenceSecond
var Diffms = Tday.getTime() - time.getTime()
DifferenceHour = Math.floor(Diffms / daysms)
Diffms -= DifferenceHour * daysms
DifferenceMinute = Math.floor(Diffms / hoursms)
Diffms -= DifferenceMinute * hoursms
DifferenceSecond = Math.floor(Diffms / Secondms)
Diffms -= DifferenceSecond * Secondms
var dSecs = Math.floor(Diffms / microsecond)
if(convertHour != DifferenceHour) document.formnow.dd.value=DifferenceHour
if(convertMinute != DifferenceMinute) document.formnow.hh.value=DifferenceMinute
if(convertSecond != DifferenceSecond) document.formnow.mm.value=DifferenceSecond
document.formnow.ss.value=dSecs
// document.formnow.Tnow.value= DifferenceHour DifferenceMinute + DifferenceSecond + dSecs
setTimeout("clock()",1000)
}
// end hiding -->
</script>
</head>
<!--BODY裡面的ONLOAD注意-->
<body onload="clock();return true" text="red">
<!--實現顯示-->
<form name="formnow">
<input name="dd" type="text" style="border:0;" size=2>

<input name="hh" type="text" style="border:0;" size=2>
小時
<input name="mm" type="text" style="border:0;" size=2>

<input name="ss" type="text" style="border:0;" size=2>

</form>
<!--倒計時完畢-->
這個是php的
<?php
/**************************************
**功能:PHP實時倒計時
**創建日期:2009-2-26
**作者:潘繼強 <[email protected]>
**
***************************************/
//php的時間是以秒算。js的時間以毫秒算

date_default_timezone_set("Asia/Hong_Kong");//地區

//配置每天的活動時間段
$starttimestr = "09:00:00";
$endtimestr = "18:30:00";
$starttime = strtotime($starttimestr);
$endtime = strtotime($endtimestr);
$nowtime = time();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP實時倒計時!</title>
<script language="JavaScript">
<!-- //
var EndTime=<?=$endtime*1000?>;
var NowTime = new Date();
//計算出伺服器和客戶端的時間差。
var dTime = NowTime.getTime()-<?=$nowtime*1000?>;
var runtimes = 0;
function GetRTime(){
var NowTime = new Date();
var dTimeNew = NowTime.getTime()-<?=$nowtime*1000?>;
var dTimesM = Math.abs(Math.floor((dTimeNew-runtimes*1000-dTime)/1000));//客戶端時間和伺服器當前時間的差
if (dTimesM>1) {//如果用戶修改了客戶端時間,就重新load本頁
window.location.reload();
}
var nMS = EndTime - NowTime.getTime()+dTime;
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("RemainH").innerHTML=nH;
document.getElementById("RemainM").innerHTML=nM;
document.getElementById("RemainS").innerHTML=nS;
if(nMS>5*59*1000&&nMS<=5*60*1000)
{
alert("還有最後五分鍾!");
}
runtimes++;

setTimeout("GetRTime()",1000);
}
window.onload=GetRTime;
// -->
</script>
</head>
<body>
<h1><strong id="RemainH">XX</strong>:<strong id="RemainM">XX</strong>:<strong id="RemainS">XX</strong></h1>
</body>
</html>

實例3:
思路不同,簡單多了.
<?php
/**************************************
**功能:PHP實時倒計時
**創建日期:2009-2-26
**作者:潘繼強 <[email protected]>
**
***************************************/
//php的時間是以秒算。js的時間以毫秒算

date_default_timezone_set("Asia/Hong_Kong");//地區

//配置每天的活動時間段
$starttimestr = "09:00:00";
$endtimestr = "13:50:00";

$starttime = strtotime($starttimestr);
$endtime = strtotime($endtimestr);
$nowtime = time();
if ($nowtime<$starttime){
die("活動還沒開始,活動時間是:{$starttimestr}至{$endtimestr}");
}
$lefttime = $endtime-$nowtime; //實際剩下的時間(秒)
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP實時倒計時!</title>
<script language="JavaScript">
<!-- //
var runtimes = 0;
function GetRTime(){
var nMS = <?=$lefttime?>*1000-runtimes*1000;
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("RemainH").innerHTML=nH;
document.getElementById("RemainM").innerHTML=nM;
document.getElementById("RemainS").innerHTML=nS;
if(nMS>5*59*1000&&nMS<=5*60*1000)
{
alert("還有最後五分鍾!");
}
runtimes++;
setTimeout("GetRTime()",1000);
}
window.onload=GetRTime;
// -->
</script>
</head>
<body>
<h1><strong id="RemainH">XX</strong>:<strong id="RemainM">XX</strong>:<strong id="RemainS">XX</strong></h1>
</body>
</html>
另外,樓下的那個冷笑天只是一個秒錶,不知道樓主要的是秒錶還是倒計時,要是還有什麼其他需要或者代碼看不懂的,m我
呵呵呵

㈡ 求倒計時代碼,js,php都行。格式: 距高考還有 145 天

echo'距2015年高考還有'.(strtotime('2015-06-07')-strtotime(date('Y-m-d')))/(24*3600).'天';

閱讀全文

與phpjs倒計時相關的資料

熱點內容
如何刪除己下載未安裝的文件 瀏覽:806
招商銀行app怎麼登陸二類卡 瀏覽:508
谷歌瀏覽器的debug調試工具 瀏覽:163
哪個數控編程是免費的 瀏覽:368
蘋果7plus玫瑰金報價 瀏覽:800
杭州自行車系統微信號 瀏覽:352
網路語偷豬是什麼意思 瀏覽:309
三星i9300線刷教程圖解 瀏覽:248
編程競賽特訓哪裡好 瀏覽:28
提取驅動文件 瀏覽:102
如何壓縮wps文件 瀏覽:314
ps轉ico文件 瀏覽:303
無編程計算器是指哪些 瀏覽:852
jquery伺服器返回json數據格式 瀏覽:375
pl0編譯程序文本c版本 瀏覽:687
cocos2djs開發 瀏覽:124
怎麼取消蘋果電腦密碼怎麼設置 瀏覽:950
word2013序列號 瀏覽:462
fu是什麼海淘網站 瀏覽:620
u盤和充電器數據線哪個好 瀏覽:969

友情鏈接