Skip to content

How to get date only value from mysql date column? #3298

Answered by RomainLanz
tsulatsitamim asked this question in Help
Discussion options

You must be logged in to vote

Hey @tsulatsitamim! 👋🏻

When defining your column, use the @column.date() decorator.

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

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@tsulatsitamim
Comment options

@thetutlage
Comment options

@tsulatsitamim
Comment options

Answer selected by thetutlage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants