user10493107
user10493107

Reputation: 141

Is it possible to change the date format?

I use a PostgreSQL and ORM Sequelize database. And I want to change the date format from YYYY-MM-DD to DD.MM.YYYY. Is it possible to do this?

    ...
    date_work: {
        type: Sequelize.DATEONLY,
        required: true  
    },
    ...

Upvotes: 2

Views: 6705

Answers (1)

Inderjeet Singh
Inderjeet Singh

Reputation: 566

You can do it using Moment like

sequelize.define('TableName', {
  DateTime: {
    type: DataTypes.DATEONLY,
    get: function() {
       return moment(this.getDataValue('DateTime')).format('DD.MM.YYYY')
    }
  }
}

Upvotes: 5

Related Questions