Format date field to display on the EJS page with Node.Js

Asked

Viewed 13 times

1

I am using Node.JS to retrieve data from a Mysql table, but I would like the date field to be displayed in the EJS view in the "DD/MM/YYYY" format. Showing "Thu Jul 15 2021 18:00:00 GMT-0300 (GMT-03:00)"

const Pedido = connection.define('pedido',{ 
   numero:{
       type: Sequelize.STRING(10),
       allowNull: true
   },
   dataemissao:{
       type: Sequelize.DATE,
       allowNull: true
   }
...

The EJS view looks like this;

<% pedidos.forEach(pedido=>{%>                                                          
    <td><%=pedido.cliente.nome%></td>
    <td><%=pedido.dataemissao%></td>
<%});%>         
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.