Datetime formatting / customization in ejs

后端 未结 6 1909
清歌不尽
清歌不尽 2021-02-07 04:09

I show date by this in ejs

<%= new Date();%>

it give me result

Tue Feb 02 2016 16:02:24 GMT+0530 (IST)

6条回答
  •  孤独总比滥情好
    2021-02-07 05:01

    Post is old but in case anyone runs into the issue.

    You can eliminate installing moment and write one little line of code. adding .toDateString() will provide you with the above format in ejs.

    however, Moment is used for more detailed date, such as Day, or month or year etc...

提交回复
热议问题