MomentJS記錄下開發中用到的日期

2021-10-09 13:34:06 字數 530 閱讀 7130

1、計算當前周一到週日的日期

​​​​​​​var weekofday = moment().format('e');//計算今天是這週第幾天

var last_monday = moment().subtract(weekofday-1, 'days').format('yyyy/mm/dd');//周一日期

var last_sunday = moment().add(7-weekofday, 'days').format('yyyy/mm/dd');//週日日期

2、計算2個時間相差幾天

//需要對比的時間

let m1 = moment("2020-01-05").format("yyyy-mm-dd");

//當前時間

let m2 = moment().format("yyyy-mm-dd");

//計算相差的天數

moment(m2).diff(moment(m1), "days");

MomentJS記錄下開發中用到的日期

1 計算當前周一到週日的日期 var weekofday moment format e 計算今天是這週第幾天 var last monday moment subtract weekofday 1,days format yyyy mm dd 周一日期 var last sunday moment...

只是記錄下

一直覺得愉悅工作,是生活的非常重要之組成部分,工作除了能提供物質上的滿足之外,同時也是影響著精神狀態的某些部分。比如成就感。工作形式各異,但不影響我們對精神上某種共識。無論是誰,還是需要這樣乙份工,來豐腴下自己的生活,不管你為的是什麼!物質也好精神也罷,我們只是都想帶著某些目標生活,才能了以慰藉這並...

記錄下Vm 學習

a b not not a b not a and not b not a or b not a ornot b not a and b p指的是not or,如p a,b not a or b p a,b a b not a p a,a and a,b p p a,a p b,b or a,b p...