0
I am using knex together with postgres and created a Migrations table.date('birth').notNull()
, in the postgres table when I do a query the date is saved in the format 1996-08-06, but when I call the get function to load user data into form inputs for editing the date appears in this format within the input 1996-08-06T03:00:00.000Z. How do I format this date and receive it in my input in DD/MM/YYYY format ?
I’m using Axios, javascript with Vue and Node in the backend.
const get = (req, res) => {
app.db('users')
.select('id', 'name', 'email', 'birth', 'admin')
.whereNull('deletedAt')
.then(users => res.json(users))
.catch(err => res.status(500).send(err))
}
exports.up = function(knex, Promise) {
return knex.schema.createTable('users', table => {
...
table.date('birth').notNull()
...
})
};
<b-form-input
v-model="user.birth"
required
id="user-birth"
type="text"
max="3000-01-01"
onfocus="(this.type='date')"
:readonly="mode === 'remove'"
placeholder="Data de nascimento"
/>
My code, I want to format the date I’m getting from the backend to the format without Timezone in that frontend input. there’s no way I can be more specific than that.