我正在使用时刻对象作为日期。为此我写了
dateOnly = moment(date.format("MM/DD/YYYY"));
var ndate = dateOnly.toDate();
我只想在前端显示日期,但它以我不想要的格式显示我
2016 年 2 月 22 日星期一 00:00:00 GMT+0530(印度标准时间)
您可以使用 moment 格式功能以您想要的格式显示日期
moment().format('MM/DD/YYYY'); // "02/22/2016"
您可以在此处浏览所有可用的格式
http://momentjs.com/docs/#/displaying/
var dateOnly = moment(date).format('MM/DD/YYYY'); // for formatted dates.
yesterday= moment(date).subtract(1,'days') // for previous day
//you can replace days with months and years.
tomorrow= moment(date).add(1,'days') // for upcoming day
//you can replace days with months and years.
var date1= moment(yesterday)
var date2= moment(tomorrow)
differencebetweenmoments =moment(date1).diff(moment(date2),'days');