问题
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?
回答1:
With moment version 1.7 and above, just use startOf method.
var date2 = date1.clone().startOf('day');
See http://momentjs.com/docs/#/manipulating/start-of/
回答2:
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
来源:https://stackoverflow.com/questions/23758345/how-to-get-date-without-time-in-existing-momentjs-object