How can I remove time from date with Moment.js?

后端 未结 11 2254
予麋鹿
予麋鹿 2020-11-28 03:04
formatCalendarDate = function (dateTime) {
    return moment.utc(dateTime).format(\'LLL\');
};

It displays: \"28 februari 2013 09:24\"

But

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 03:55

    Okay, so I know I'm way late to the party. Like 6 years late but this was something I needed to figure out and have it formatted YYYY-MM-DD.

    moment().format(moment.HTML5_FMT.DATE); // 2019-11-08
    

    You can also pass in a parameter like, 2019-11-08T17:44:56.144.

    moment("2019-11-08T17:44:56.144").format(moment.HTML5_FMT.DATE); // 2019-11-08
    

    https://momentjs.com/docs/#/parsing/special-formats/

提交回复
热议问题