Format conversion and time calculates the time difference

 

 

//标准时间转年月日时分秒时间格式
function formatDateTime(date) {
  let y = new Date(date).getFullYear();
  let m = new Date(date).getMonth() + 1;
  m = m < 10 ? "0" + m : m;
  let d = new Date(date).getDate();
  d = d < 10 ? "0" + d : d;
  let h = new Date(date).getHours();
  h = h < 10 ? "0" + h : h;
  let minute = new Date(date).getMinutes();
  minute = minute < 10 ? "0" + minute : minute;
  SECOND the let = new new a Date (DATE) .getSeconds (); 
  SECOND = SECOND <10 "0" +? SECOND: SECOND;
   return Y + "-" + m + "-" + D + "" + H + ":" minute + + ":" + SECOND; 
}; 
// the standard time format, calculate the time difference -> number of minutes 
function standardGetInervalMinute (startDate, endDate) { 
  the let MS = new new a Date (endDate) .getTime () - new new a Date (startDate). the getTime ();
   return MS / 1000/60 ; 
};

 

Guess you like

Origin www.cnblogs.com/XUYIYUAN/p/11297972.html