function countDate(_start, _end, _this)
{
var now = new Date();
var time = now.getTime();
var now_sec = Math.floor(time/1000);//获得当前的秒级时间戳
if(now_sec < _start){
var leftsecond = _start - now_sec; //计算时间戳差值
var day=Math.floor(leftsecond/(3600*24))
var hour=Math.floor((leftsecond-day*3600*24)/3600);
var minute=Math.floor((leftsecond-day*3600*24-hour*3600)/60);
var second=Math.floor(leftsecond-day*3600*24-hour*3600-minute*60);
var dateHtml = '即将开始:<b>'+day+'天'+hour+'小时'+minute+'分'+second+'秒</b>,快叫上好友一起来抢购吧~';
}else if(_start <= now_sec && now_sec < _end){
var leftsecond = _end - now_sec; //计算时间戳差值
var day=Math.floor(leftsecond/(3600*24))
var hour=Math.floor((leftsecond-day*3600*24)/3600);
var minute=Math.floor((leftsecond-day*3600*24-hour*3600)/60);
var second=Math.floor(leftsecond-day*3600*24-hour*3600-minute*60);
var dateHtml = '剩余:<b>'+day+'天'+hour+'小时'+minute+'分'+second+'秒</b>,抓住机会来抢购吧~';
}else if(_end <= now_sec){
var dateHtml = '已结束'
}
_this.html(dateHtml);
}
网友评论