Normalizing all dates
Lucid currently normalize only default (created_at and updated_at) fields to 'YYYY-MM-DD HH:mm:ss'
But if we have some custom timestamp field like
table.timestamp('published_at')
and fill 'published_at' with something like 'new Date().toISOString()', Lucid doesn't normalize it to 'YYYY-MM-DD HH:mm:ss'.
Though If we fill 'created_at' with 'new Date().toISOString()' Lucid does normalize it.
I think formatting all timestamp fields to this default 'YYYY-MM-DD HH:mm:ss' would be more expected behavior... And docs tell us the same :)
Lucid formats all dates as YYYY-MM-DD HH:mm:ss by default, which is a valid format for all database engines.
Hey @PazzaVlad! 👋
Have you defined the date into the model? http://adonisjs.com/docs/4.0/lucid#_dates
oh, I don't know how I overlook that in docs :( Thanks) This solves the problem
static get dates () {
return super.dates.concat(['published_at'])
}
Cool! Closing then 😄