登录
2017-01-08 15:33:21 来自:什么什么 1 人回应
<script language="javascript" type="text/javascript">
var interval = 100;
function ShowCountDown(year,month,day,divname)
{
var now = new Date();
var endDate = new Date(year, month-1, day);
var leftTime=endDate.getTime()-now.getTime();
var leftsecond = parseInt(leftTime/1000);
//var day1=parseInt(leftsecond/(24*60*60*6));
var year=Math.floor(leftsecond/(60*60*24*365));
var day1=Math.floor(leftsecond/(60*60*24));
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
var cc = document.getElementById(divname);

cc.innerHTML = "<h2>"+day1+"天"+hour+"小时"+minute+"分"+second+"秒"+"</h2>";
if(second.length<2)
{
second.innerHTML ="0"+second;
}
}
window.setInterval(function(){ShowCountDown(2017,1,27,'divdown1');}, interval);
</script>
2017-01-09 6:59:23 来自:small_帅

写一个补充方法.所有的输出都调用这个方法.

方法就是输入一个字符串.再输入一个最小长度.当长度不够是在恰面加0补满.

PS.net的string里是自带的.js不知道

您的回应

你还未登陆,不能回应!登陆