導航:首頁 > 編程語言 > php計時代碼

php計時代碼

發布時間:2022-06-11 13:49:30

『壹』 php中怎樣實現倒計時功能

可以考慮asp實現:

1.HiddenField 控制項儲存時間
<!--2700秒時間-->
<asp:HiddenField ID="hidTime" runat="server" Value="2700" />
2.js代碼
<script language="javascript" type="text/javascript">

var time;
var minutes;
var seconds;
var str;
function ShowTime2() {
if(document.getElementById("btnSubmitExam") !=null)
{
time = document.getElementById("hidTime").value;

time = time - 1;
document.getElementById("hidTime").value = time;
minutes = parseInt(time / 60);
seconds = time % 60;

document.getElementById("DjTimeDiv").innerHTML = "剩餘時間:" + minutes + "分鍾" + seconds + "秒";
if (time == 1) {
document.getElementById("DjTimeDiv").innerHTML="剩餘時間:0分鍾0秒";
document.getElementById ("btnSubmitExam").click();
// window.close();
}else
{
setTimeout("ShowTime2()", 1000);
}

}else
{
document.getElementById("DjTimeDiv").innerHTML="剩餘時間:0分鍾0秒";
}
}

</script>

『貳』 求大神寫斷倒計時代碼 php,js皆可

這是我之前網上找到改的,只是個建議,希望對你有用。如果使用到的話,要記住調用jquery.js

css代碼:
/* 距離結束時間 */
.overtime{
padding: 10px 0;
font-size: 14px;
border-bottom: 1px dashed #FFCC8F;
}
.overtime div{
white-space: nowrap;
overflow: hidden;
}
.overtime .times{
margin-top: 10px;
height: 30px;
line-height: 15px;
white-space: nowrap;
overflow: hidden;
}
.overtime .times span{
display: inline-block;
width: 40px;
height: 30px;
line-height: 30px;
text-align: center;
background: url("../images/times_bg.png") no-repeat;
margin: 0 3px;
font-size: 20px;
color: #fff;
}


html代碼:
<div class="overtime">
<div>距離秒殺結束時間還有:</div>
<div class="times">
<span id="day">-</span>天
<span id="hour">-</span>小時
<span id="minute">-</span>分
<span id="second">-</span>秒
</div>
</div>

<script type="text/javascript">
$(function(){
countDown("2014/8/8 23:59:59",".times #day",".times #hour",".times #minute",".times #second");
});

function countDown(time,day_elem,hour_elem,minute_elem,second_elem){
var end_time = new Date(time).getTime(),//月份是實際月份-1
//current_time = new Date().getTime(),
sys_second = (end_time-new Date().getTime())/1000;
var timer = setInterval(function(){
if (sys_second > 1) {
sys_second -= 1;
var day = Math.floor((sys_second / 3600) / 24);
var hour = Math.floor((sys_second / 3600) % 24);
var minute = Math.floor((sys_second / 60) % 60);
var second = Math.floor(sys_second % 60);
day_elem && $(day_elem).text(day);//計算天
$(hour_elem).text(hour<10?"0"+hour:hour);//計算小時
$(minute_elem).text(minute<10?"0"+minute:minute);//計算分
$(second_elem).text(second<10?"0"+second:second);// 計算秒
} else {
$(day_elem).text(0);//計算小時
$(hour_elem).text("00");//計算小時
$(minute_elem).text("00");//計算分
$(second_elem).text("00");// 計算秒
clearInterval(timer);
}
}, 1000);
}
</script>

『叄』 php在網頁里使用倒計時的代碼,想每次點開網頁 都以一個隨機的數開始倒計時~

你不能把PHP和JS混淆了,你前面的$year賦值的兩句是無效的,應該使用js代碼生成隨機數,例如:
year=2013+Math.round(Math.random()*20);

『肆』 PHP怎麼製作計時器

計時器的運用在網頁製作中很普遍,其實計時器有很多做法,PHP加JS、JS加AJAX也可以控制實現。不是PHP可以單獨實現的,因為PHP是實現服務端的語言,沒有辦法去控制。以下實例就是製作計時器的代碼:

<SCRIPTlanguage=JAVASCRIPT>
vartimerID=null;
vartimerRunning=false;
functionstopclock()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning=false;
}
functionstartclock()
{
stopclock();
showtime();
}
functionshowtime()
{
varnow=newDate();
varhours=now.getHours();
varminutes=now.getMinutes();
varseconds=now.getSeconds()
vartimeValue=""+hours;
//定時初始化資料庫的代碼:
timeValue+=((minutes<10)?":0":":")+minutes
timeValue+=((seconds<10)?":0":":")+seconds
document.Calc.time.value=timeValue;
//
//andhaveaclockonthestatusbar:
//window.status=timeValue;
timerID=setTimeout("showtime()",1000);
timerRunning=true;
return'';
}</script>
客服端PHP+HTML代碼:
<html>
<head>
<METAHTTP-EQUIV="Refresh"Content="1;URL=test.php">
</head>
<body>
<?
echodate("Y年m月d日H時i分s秒");
?>
</body>
</html>

『伍』 求一24小時倒計時代碼有開始時間,最好是PHP的

<DIV class=aoyun><FONT <p> <p><font size="3">倒計時距離XX還有:</font></p></FONT><SPAN id=span_dt_dt></SPAN>
<SCRIPT language=javascript>
<!--
//document.write("");
function show_date_time(){
window.setTimeout("show_date_time()", 1000);
BirthDay=new Date("8/22/2008 16:00:00");//這個日期是可以修改的
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML="<align=center><p><font color=#A22900><p><font size=4>"+daysold+"天"+hrsold+"小時"+minsold+"分"+seconds+"秒"+"<br></font><br></font>" ;
}
show_date_time();
//-->
</SCRIPT></td>
</tr>
</table>
</div>
<br></div>
<div>

『陸』 一個PHP環境下商品搶購倒計時的代碼

代碼是沒有,如果你懂PHP應該可以理解這個當然要在後台設定商品開搶時間 。然後存入數據,包括 開始時間 和 持續時間頁面讀取資料庫中的時間開始時間出來,和當時的時候進行比較如果 到達這個日期 就開始顯示倒計,如果 到達 並 兩個時間的差 大於了 持續時間,就宣布搶購結束至於如何動態顯示了,那就得利用 JAVASCRIPT 了 而倒計的起始時間就是 把 (開始時間+持續時間)-現在時間
這樣,即使刷新頁 也是越來越少的起始倒計時。。。一分前是 離結束還有:5小時25分25秒,一分鍾你刷新後,那麼倒計時起始時間應該是 離結束還有:5小時24分25秒 然後由JAVASCRIPT再一秒一秒的減 商品在添加的時候,應該有一個數據是當作庫量來用的,每成功購買一次後,程序相應的要去 資料庫中進行更新 即 庫存量減1 代碼沒有,如果你不懂,代碼貼出來你都不知道放哪。。
只能拋誇引玉了。。 自己思考下。。

『柒』 求php倒計時代碼

下面的例子程序就可以:

<div id='r'>0</div>
<script language="javascript">
var x=20*60;
function shw()
{
document.getElementById('r').innerHTML='還剩下'+parseInt(x/60)+'分'+parseInt(x%60)+'秒';
x--;
if (x<0) {alert('時間到');}
else setTimeout('shw();',1000);
}
shw();
</script>

補充:
時間到了自動提交表單,可以使用下面的代碼(替換上面測試裡面的alert):
document.form1.submit();

上面的form1是表單的名稱,例如:
<form name=form1 ...>

『捌』 PHP倒計時代碼修改 倒計時時間錯誤

只需要將var startTime = (new Date("August,8,2008,20:00,")).getTime();

=============》》》》》》改成

var startTime = (new Date("April,14,2009,20:00,")).getTime();

!!!!其中August是八月,April是四月!!!!!!!

我已經調試成功 結果為:★★★★★現在距北京奧運會還有: 264天 03:47:53★★★★★

若按linkzq所說改成var startTime= (new Date(2009,4,14)).getTime(); 則結果為★★★★★現在距北京奧運會還有: 已開始< >★★★★★

『玖』 高分求一段 PHP 實時顯示倒計時 代碼

<div id="time"><span id="liveclock"></span>
<script type="text/javascript" >
function YaoShuai_time()
{
var Digital=new Date();
var hours=Digital.getHours();
var minutes=Digital.getMinutes();
var seconds=Digital.getSeconds();
var year=Digital.getFullYear();
var month=Digital.getMonth()+1;
var day=Digital.getDate();
var modhour=23-hours;
var modminute=59-minutes;
var modsecond=60-seconds;
if(month<=9) month="0"+month;
if(day<=9) day="0"+day;
if(minutes<=9) minutes="0"+minutes;
if(seconds<=9) seconds="0"+seconds ;
myclock="當前時間: "+year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds+"剩餘時間"+modhour+":"+modminute+":"+modsecond;
if(document.layers){
document.layers.liveclock.document.write(myclock);
document.layers.liveclock.document.close();
}else {
document.getElementById('liveclock').innerHTML=myclock;
}
setTimeout("YaoShuai_time()",1000)
}
YaoShuai_time();
</script>
</div>

閱讀全文

與php計時代碼相關的資料

熱點內容
怎麼截取app接受的數據 瀏覽:274
nrf24l01pdf 瀏覽:296
php字元串轉array 瀏覽:432
U盤分了文件夾後 瀏覽:938
javasetstring 瀏覽:835
壓縮包里文件夾是白色的 瀏覽:470
編譯鏈接知乎 瀏覽:589
php查詢按鈕 瀏覽:713
有音響游戲解壓神器 瀏覽:251
怎麼壓縮圖片jpeg 瀏覽:711
澳大利亞net程序員 瀏覽:577
程序員加班難受 瀏覽:986
如何看伺服器品牌 瀏覽:254
ecy50clp壓縮機多少W 瀏覽:753
mac終端命令怎麼保存 瀏覽:848
微信公眾號圖片壓縮 瀏覽:438
可以在安卓平板上畫畫的軟體是什麼 瀏覽:436
高盛數字加密 瀏覽:895
軟著網上能不能查到自己的源碼 瀏覽:915
編譯好的android源碼 瀏覽:993