javaScript custom formats and returns the system time countdown

 function gettime(){
     var date=new Date();
     var year=date.getFullYear();
     var month=date.getMonth();
     var day=date.getDate();

     var hour=date.getHours();
     var minute=date.getMinutes();
     var second=date.getSeconds();
     function addZero(time){
       return time>10?time:'0'+time;
     }

     return year+'-'+addZero(month)+'-'+addZero(day)+' '+addZero(hour)+':'+addZero(minute)+':'+addZero(second);
   }
   console.log(gettime());

 

 // 1, get next time acquisition timestamp 
   var End + = new new a Date ( '= 2019 at 10-15'); // current date 2019-10-13 
   // 2, acquire the current time stamp 
   var now + = new new DATE ();
    // 3. time difference 
   var time = the parseInt ((End-now) / 1000); // s
    // 4 days 
   var day = the parseInt (time / 60/60/24);
    the console.log (day );
    // 5, less than 24 hours hours 
   var hour = the parseInt (Time / 60/60) 24% ;
   console.log(hour);
   // 6, less than six minutes to get out of the 
   var minute = the parseInt (Time / 60) 60%;
    the console.log (minute);
    // . 7, less than sixty seconds to get the second 
   var SECOND Time = 60% ;
   console.log(second);

   var STR = 'lottery dates from:' + day + 'day' + hour + 'h' + minute + 'points' + second + 's' ;
   console.log(str);

 

Guess you like

Origin www.cnblogs.com/f2ehe/p/11666290.html