Joke Collection Website - Blessing messages - JS countdown, how much time is left before a certain date?
JS countdown, how much time is left before a certain date?
The code is as follows:
& lt span? Id = "show"> loading ... & lt/span>.
& lt script? type = " text/JavaScript " & gt;
//time_val? Compare time? Format: 2016-12-14? 22:55:40
Function? Countdown (time value) {
var? www_qsyz_net=/^[\d]{4}-[\d]{ 1,2}-[\d]{ 1,2}(? [\d]{ 1,2}:[\d]{ 1,2}(:[\d]{ 1,2})? )? $/ig,str= ' ',conn,s;
If (! time_val.match(www_qsyz_net)){
Alert ('parameter format is 2012-01-01[? 01:01[:01]]. \ r [] can be omitted');
Return? Fake;
}
var? Sec= (new? Date(time_val.replace(/-/ig,'/'))。 getTime()? -? New? Date (). getTime())/ 1000;
If (seconds? & gt? 0){
conn= '? "Then what?";
} Otherwise {
conn= '? "Has it passed?";
sec * =- 1;
}
S={' days': sec/24/3600,' hours': sec/3600%24,' minutes': sec/60%60,' seconds ':sec % 60 };
For (me? Are you online? s){
if(math . floor(s[I])& gt; 0? )? str? +=? Math.floor(s[i])? +? Me;
}
if(Math.floor(sec)==0){? Str = "0 seconds"; ? }
document.getElementById('show ')。 innerHTML? =? Distance? & ltu & gt? +? time_val? +? '& lt/u & gt; ? +? Kang En? +' & lt; u & gt? +? str? +? '& lt/u & gt; ;
//Update once every second
setTimeout(function(){ count down(time _ val)}, 1000);
}
Countdown ('2016-12-14? 22:55:40');
& lt/script & gt;
- Previous article:Why doesn't my Huawei mobile phone have an extended password?
- Next article:What if Samsung's smartphone is hacked?
- Related articles
- How do people in Taiwan Province Province receive short messages?
- My Beijing Unicom 1 year broadband service expires, and I will extend it in the same month 1 year. Will it take effect in the same month?
- Is the notice of trial a text message?
- Sixty anti-epidemic slogans of inspirational positive energy
- What do you think of Evergrande's announcement on September 18 that all the money required by the senior management to be redeemed in advance should be returned within a time limit? What does this mea
- How to clear the memory of Xiaomi k30
- Birthday wishes are short.
- How to block unwanted calls? Can I set it on my mobile phone?
- Personal Work Report and Summary of Anti-telecom Fraud in 2022
- Will there be any news if the loan can't buy a house?