How to get date only value from mysql date column? #3298
Answered
by
RomainLanz
tsulatsitamim
asked this question in
Help
-
how to get |
Beta Was this translation helpful? Give feedback.
Answered by
RomainLanz
Nov 2, 2021
Replies: 2 comments 3 replies
-
You can use serialize method: https://docs.adonisjs.com/guides/models/serializing-models#mutatingtransforming-values @column.dateTime({
autoCreate: true,
serialize: (value: DateTime | null) => {
return value ? value.toFormat('yyyy-MM-dd') : value
},
})
public created_at: DateTime |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey @tsulatsitamim! 👋🏻 When defining your column, use the import { DateTime } from 'luxon'
import { column, BaseModel } from '@ioc:Adonis/Lucid/Orm'
class User extends BaseModel {
@column.date()
public dob: DateTime
} 📚 https://docs.adonisjs.com/reference/orm/decorators#columndate--columndatetime |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
thetutlage
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @tsulatsitamim! 👋🏻
When defining your column, use the
@column.date()
decorator.📚 https://docs.adonisjs.com/reference/orm/decorators#columndate--columndatetime