Let's say I have momentjs object like the following:
var date = moment(new Date(2014,2,17,9,60));
How could I get clone and get new momentjs object without time?
Let's say I have momentjs object like the following:
var date = moment(new Date(2014,2,17,9,60));
How could I get clone and get new momentjs object without time?
With moment version 1.7 and above, just use startOf method.
var date2 = date1.clone().startOf('day');
The momentjs object will always store a time, regardless of whether you use it. However, the following will clone date
to date2
and reset the time:
var date2 = date.clone().hour(0).minute(0).second(0).millisecond(0)
You'll now have two independent momentjs objects date
and date2
You also can do this as follows.
moment().format('LL'); // September 02, 2020
moment().format('YYYY-MM-DD'); // 2020-09-02