I show date by this in ejs
<%= new Date();%>
it give me result
Tue Feb 02 2016 16:02:24 GMT+0530 (IST)
For a better code management, you can add the code(below) in app.js/server.js. This will save moment
in the res.locals.moment
at the time of starting the app. By doing this you can access the moment
variable from any ejs page.
app.js/server.js:
const express = require("express");
const app = express();
const moment = require("moment");
app.use((req, res, next)=>{
res.locals.moment = moment;
next();
});
something.ejs
<%= moment(yourDateVariable).format('Do MMMM, YYYY') %>
Here Do
will result with 19th
.You can check it here https://momentjs.com/docs/#/displaying/format/. Hope this will help.