How do I get a date in YYYY-MM-DD format?

前端 未结 10 860
一生所求
一生所求 2020-12-17 17:16

Normally if I wanted to get the date I could just do something like

var d = new Date(); console.log(d);

The problem with doing that, is when I

10条回答
  •  长情又很酷
    2020-12-17 17:58

    By using moment.js library, you can do it:

    var datetime = new Date("2015-09-17 15:00:00"); datetime = moment(datetime).format("YYYY-MM-DD");

提交回复
热议问题