I show date by this in ejs
<%= new Date();%>
it give me result
Tue Feb 02 2016 16:02:24 GMT+0530 (IST)
But I need to show as
19th January, 2016
How can I do this in ejs?
You can use moment
In your controller,
var moment = require('moment');
exports.index = function(req, res) {
res.render('index', { moment: moment });
}
In your html,
<html>
<h1><%= moment().format('Do MMMM, YYYY'); %></h1>
</html>
If you can live without ordinal day (th, nd, rd etc) you could use basic JS
<%= new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: '2-digit'}).format(new Date()) %>
// Expected output: 25 August 2020