如何实现象淘宝网拍卖里边那种剩余时间的显示啊? 也可以在下载页面的时候给各初始值,然后用javascript定时递减显示。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是啊,同意楼上的xyzxyz,gamespot上的体育版也是这样做的.关键是如何取得服务器上的时间,用javascript可能是取不到的.现在有许多网也上的时间,只要在自己的电脑上改一下就露馅了!有高手能给个服务器上的时间的代码,最好是javascript的哦! 不是实时的倒计时,不用JS,反之则用程序先取得剩余时间,再用JS动态进行,和客户端无关。 给个开头例子给你,你再改一下应该可以了,这个是我当时面试时留下来的作品,面试官要我当场做出来的,当时真的有点难倒我了,好在还是弄出来了。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>时间测试</title></head><body><?php$server_time = time();function onload_js($server_time){echo <<<EOT<SCRIPT LANGUAGE=Javascript> var secondServer = $server_time;//到得服务器系统时间 var dateDayWeek = new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六"); var dateDayMonth = new Array("01","02","03","04","05","06","07","08","09","10","11","12"); var secondClient = parseInt(new Date().getTime()/1000); var secondSub = secondServer - secondClient; var timerID = null; var timerRunning = false; startClock(secondServer);function stopClock(){ if (timerRunning) clearTimeout(timerID); timerRunning = false;}function showTime(){ var now = new Date(); now.setTime(now.getTime()+secondSub*1000); var nowYear = now.getYear(); var nowMonth = now.getMonth(); var nowDate = now.getDate(); var nowDay = now.getDay(); var nowHours = now.getHours(); var nowMinutes = now.getMinutes(); var nowSeconds = now.getSeconds(); if (nowYear<2000) nowYear = "19"+nowYear; if (nowMinutes<10) nowMinutes = "0"+nowMinutes; if (nowSeconds<10) nowSeconds = "0"+nowSeconds; myClock = "<font size='4' face = 'Arial' color = 'blue'>现在时间是: " + nowYear + "-" + dateDayMonth[nowMonth] + "-" + nowDate + " "+nowHours + ":" + nowMinutes + ":" + nowSeconds+" "+ dateDayWeek[nowDay] +"</b></font>"; if (document.layers){ document.layers.position.document.write(myClock); document.layers.position.document.close(); } else if (document.all) position.innerHTML = myClock; timerID = setTimeout('showTime(secondSub)',1000); timerRunning = true;}function startClock(){ stopClock(); showTime();}</SCRIPT>EOT;}?><span id="position" style="position:absolute;left:300px;top:190px; width: 600px; height: 30px"><br><?onload_js($server_time);?></body></html> parseInt(new Date().getTime()/1000);得到的不是服务齐的时间吧?为什么叫$server_time?? 求助 PHP如何开发接口问题 给一维数组赋值,结果成了二维数组的奇怪现象 求将MSSQL数据导入到MYSQL里,很急啊! ■■■大家的网站有无试过无缘无故被百度取消收录? php socket 的问题 在多层次的frameset中我无法关闭其中的一个frame,不知道为什么? PHP4.0中的数据库连接问题 如何在数据库中建一个表,当用户登录后写入该表,退出后自动删除该用户记录?? 如何做全文检索?(php+mysql) 请教一个关于查询效率的问题呗 请大家推荐一个写的比较好的PHP程序,不要太复杂。我研究研究.UP有分 页面某一区域刷新问题?
关键是如何取得服务器上的时间,用javascript可能是取不到的.
现在有许多网也上的时间,只要在自己的电脑上改一下就露馅了!
有高手能给个服务器上的时间的代码,最好是javascript的哦!
反之则用程序先取得剩余时间,再用JS动态进行,和客户端无关。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>时间测试</title>
</head>
<body>
<?php
$server_time = time();
function onload_js($server_time){
echo <<<EOT
<SCRIPT LANGUAGE=Javascript>
var secondServer = $server_time;//到得服务器系统时间
var dateDayWeek = new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");
var dateDayMonth = new Array("01","02","03","04","05","06","07","08","09","10","11","12");
var secondClient = parseInt(new Date().getTime()/1000);
var secondSub = secondServer - secondClient; var timerID = null;
var timerRunning = false; startClock(secondServer);function stopClock(){
if (timerRunning) clearTimeout(timerID);
timerRunning = false;
}function showTime(){
var now = new Date();
now.setTime(now.getTime()+secondSub*1000);
var nowYear = now.getYear();
var nowMonth = now.getMonth();
var nowDate = now.getDate();
var nowDay = now.getDay();
var nowHours = now.getHours();
var nowMinutes = now.getMinutes();
var nowSeconds = now.getSeconds(); if (nowYear<2000) nowYear = "19"+nowYear;
if (nowMinutes<10) nowMinutes = "0"+nowMinutes;
if (nowSeconds<10) nowSeconds = "0"+nowSeconds;
myClock = "<font size='4' face = 'Arial' color = 'blue'>现在时间是: " + nowYear + "-" + dateDayMonth[nowMonth] + "-" + nowDate + " "+nowHours + ":" + nowMinutes + ":" + nowSeconds+" "+ dateDayWeek[nowDay] +"</b></font>"; if (document.layers){
document.layers.position.document.write(myClock);
document.layers.position.document.close();
}
else if (document.all)
position.innerHTML = myClock; timerID = setTimeout('showTime(secondSub)',1000);
timerRunning = true;
}function startClock(){
stopClock();
showTime();
}
</SCRIPT>
EOT;
}
?>
<span id="position" style="position:absolute;left:300px;top:190px; width: 600px; height: 30px"><br>
<?
onload_js($server_time);
?>
</body>
</html>
得到的不是服务齐的时间吧?
为什么叫$server_time??