亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js 距離某一時間點(diǎn)時間是多少實(shí)現(xiàn)代碼

 更新時間:2013年10月14日 17:46:12   作者:  
距離某一時間點(diǎn)時間是多少,在本文將為大家介紹下js中是如何實(shí)現(xiàn)的,感興趣的朋友不要錯過
復(fù)制代碼 代碼如下:

<!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" xml:lang="cn">
<head>
<title>正計時</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style type="text/css">
#thenceThen{font-size:2em;}
</style>
<script type="text/javascript" language="javascript">
function thenceThen(){
var date1 = new Date(1381741113671);
var totalSecs=(new Date()-date1)/1000;
var days=Math.floor(totalSecs/3600/24);
var hours=Math.floor((totalSecs-days*24*3600)/3600);
var mins=Math.floor((totalSecs-days*24*3600-hours*3600)/60);
var secs=Math.floor((totalSecs-days*24*3600-hours*3600-mins*60));
if (days != 0 ) {
document.getElementById("thenceThen").innerText=" 答題時間:"+days+"天"+hours+"小時"+mins+"分鐘"+secs+"秒";
}else if (hours == 0 && mins == 0) {
document.getElementById("thenceThen").innerText=" 答題時間:"+secs+"秒";
}else if (hours == 0 && mins != 0) {
document.getElementById("thenceThen").innerText=" 答題時間:"+mins+"分鐘"+secs+"秒";
}else if (hours != 0) {
document.getElementById("thenceThen").innerText=" 答題時間:"+hours+"小時"+mins+"分鐘"+secs+"秒";
}
}
var clock;
window.onload=function(){
clock=self.setInterval("thenceThen()", 500);
}
</script>
</head>
<body>
<div id="thenceThen"></div>
</body>

</html>

=========================================================================================================

上文中 var date1 = new Date(1381741113671);

參數(shù)傳遞見下方(也可接收后臺參數(shù)):

參數(shù)形式有以下5種:
復(fù)制代碼 代碼如下:

new Date("month dd,yyyy hh:mm:ss");
new Date("month dd,yyyy");
new Date(yyyy,mth,dd,hh,mm,ss);
new Date(yyyy,mth,dd);
new Date(ms);

需要注意最后一種形式,參數(shù)表示的是需要創(chuàng)建的時間和GMT時間1970年1月1日之間相差的毫秒數(shù)。各種函數(shù)的含義如下:

month:用英文表示月份名稱,從January到December

mth:用整數(shù)表示月份,從(1月)到11(12月)

dd:表示一個月中的第幾天,從1到31

yyyy:四位數(shù)表示的年份

hh:小時數(shù),從0(午夜)到23(晚11點(diǎn))
mm:分鐘數(shù),從0到59的整數(shù)

ss:秒數(shù),從0到59的整數(shù)

ms:毫秒數(shù),為大于等于0的整數(shù)

如:
復(fù)制代碼 代碼如下:

new Date("January 12,2006 22:19:35");

new Date("January 12,2006");

new Date(2006,0,12,22,19,35);

new Date(2006,0,12);

new Date(1137075575000);

相關(guān)文章

最新評論