待收货倒计时
<body>
<c:forEach begin="0" end="5" step="1" varStatus="status">
<div id="divdown${status.index}"></div>
<br />
</c:forEach>
</body>
<script type="text/javascript">
function Todate(num) { //Fri Oct 31 18:00:00 UTC+0800 2008
num = num + "";
var date = "";
var month = new Array();
month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4; month["May"] = 5; month["Jan"] = 6;
month["Jul"] = 7; month["Aug"] = 8; month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;
var week = new Array();
week["Mon"] = "一"; week["Tue"] = "二"; week["Wed"] = "三"; week["Thu"] = "四"; week["Fri"] = "五"; week["Sat"] = "六"; week["Sun"] = "日";
str = num.split(" ");
date = str[5] + "-";
date = date + month[str[1]] + "-" + str[2]+"-" + str[3];
return date;
}
var interval = 1000;
function ShowCountDown(time, divname) {
var parseTime = time.replace(/-/g,"/");
var oDate1 = new Date(parseTime);
var date = new Date(oDate1.getTime() + 24*30*60*60*1000); //往后推30天
var year=date.getFullYear();//获取年份
var month=date.getMonth()+1; //获取当前月份
var day=date.getDate();
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 = 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 = "距离" + year + "年" + month + "月" + day + "日还有:"
+ day1 + "天" + hour + "小时" + minute + "分" + second + "秒";
}
<c:forEach items="${data.list.resultData}" var="data" varStatus="status">
window.setInterval(function() {
ShowCountDown(Todate('${data.transactionDate}'), 'divdown${status.index}');
}, interval);
</c:forEach>
</script>