日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

js 日期轉(zhuǎn)化

 丶平上 2016-05-24

  Date.prototype.Format = function (fmt) { //author: meizz 
   var o = {
       "M+": this.getMonth() + 1, //月份 
       "d+": this.getDate(), //日 
       "h+": this.getHours(), //小時 
       "m+": this.getMinutes(), //分 
       "s+": this.getSeconds(), //秒 
       "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
       "S": this.getMilliseconds() //毫秒 
   };
   if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
   for (var k in o)
   if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
   return fmt;
}
  //計算倒計時
var timer=setInterval(rest_time,1000); 
var aaa = 0;
var bbb = 0;
var ccc = 0;
function rest_time(){
  
var now_time = Math.round(new Date().getTime()/1000);
        //now_time = 1463733600;
var data_time = new Date().Format("yyyy/MM/dd");
var first_time1 = Date.parse(new Date(data_time+" 09:30:00")) / 1000;
//alert(data_time);
var first_time2 = Date.parse(new Date(data_time+" 11:30:00")) / 1000;
var second_time1 = Date.parse(new Date(data_time+" 13:00:00")) / 1000;
var second_time2 = Date.parse(new Date(data_time+" 15:30:00")) / 1000;
if(now_time<first_time1){
document.getElementById("next_auction_time").innerHTML="<span style='font-size:20px;'>距離下次拍賣開始還有:</span>";
aaa = 1;
bbb = 1 ;
var rest_seconds=first_time1-now_time;
rest_time_format(rest_seconds, true);
}else if(now_time>first_time1 && now_time<first_time2){
document.getElementById("auction_time").innerHTML="<span style='font-size:20px;'>距離競拍結(jié)束還有:</span>";
var rest_seconds=first_time2-now_time;
rest_time_format(rest_seconds);
document.getElementById("next_auction_time").innerHTML="<span style='font-size:20px;'>距離下次競拍開始還有:</span>";
var rest_seconds=second_time1-now_time;
aaa = 0 ;
bbb = 1 ;
ccc =0  ;
rest_time_format(rest_seconds, true);
}else if(now_time>first_time2 && now_time<second_time1){
document.getElementById("next_auction_time").innerHTML="<span style='font-size:20px;'>距離下次拍賣開始還有:</span>";

ccc = 1;
bbb = 1 ;
var rest_seconds=second_time1-now_time;
rest_time_format(rest_seconds, true);
}else if(now_time>second_time1 && now_time<second_time2){
document.getElementById("auction_time").innerHTML="<span style='font-size:20px;'>距離競拍賣結(jié)束還有:</span>";
var rest_seconds=second_time2-now_time;
rest_time_format(rest_seconds);
aaa = 0;
bbb = 1 ;
document.getElementById("next_auction_time").innerHTML="<span style='font-size:20px;'>距離下次競拍開始還有:</span>";
var rest_seconds=first_time1+24*3600-now_time;
rest_time_format(rest_seconds, true);
}else if(now_time==first_time1){
window.location.reload();
}else if(now_time==first_time2){
window.location.reload();
}else if(now_time==second_time1){
window.location.reload();
}else if(now_time==second_time2){
window.location.reload();
}else{
document.getElementById("auction_time").innerHTML="<span style='font-size:20px;'>本次拍賣已結(jié)束。</span>";
document.getElementById("next_auction_time").innerHTML="<span style='font-size:20px;'>距離下次拍賣開始還有:</span>";
var rest_seconds=first_time1+24*3600-now_time;
rest_time_format(rest_seconds, true);
bbb = 1 ;
ccc = 1 ;

}
}
//處理剩余時間顯示格式 
function rest_time_format(rest_seconds, next){
var d=Math.floor(rest_seconds/60/60/24);
   var h=Math.floor(rest_seconds/60/60%24);
   var m=Math.floor(rest_seconds/60%60);
   var s=Math.floor(rest_seconds%60);
if(next==true){
document.getElementById("next_rest_d").innerHTML = d + "天";
   document.getElementById("next_rest_h").innerHTML = h + "時";
   document.getElementById("next_rest_m").innerHTML = m + "分";
   document.getElementById("next_rest_s").innerHTML = s + "秒";
}else{
document.getElementById("rest_d").innerHTML = d + "天";
   document.getElementById("rest_h").innerHTML = h + "時";
   document.getElementById("rest_m").innerHTML = m + "分";
   document.getElementById("rest_s").innerHTML = s + "秒";
}
}

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多