Get a date of the current time on Monday

Monday's acquisition method, returns 10 digits:

// Get Mondays 
getWeeklyDay (Time) { 
  the let dd = '' 
  IF (Time) { 
    dd new new = a Date (Time) 
  } the else { 
    dd new new = a Date () 
  } 
  var dd.getDay Week = () // Get Time week number 
  ? = var minus week week -. 1:. 6 
  dd.setDate (dd.getDate () - minus) // Get date minus days before 
  var Y = dd.getFullYear () 
  var dd.getMonth m = () + // Get 1 January 
  var dd.getDate D = () 
  return a Date new new (Y + '-' + m + '-' + D) .getTime () / 1000 
},

transfer

the console.log (this.getWeeklyDay ( '2019/07/17')) 
the console.log (this.getWeeklyDay ( '2019-07-17')) 
the console.log (this.getWeeklyDay ()) // this is null date

 

Guess you like

Origin www.cnblogs.com/wgl0126/p/11200118.html