time sequelize html example stack overflow

Example 1: time sequelize html example stack overflow

var sequelize= require('../models');
    model.findAll({
            attributes: [
                       'id',
                       'title'
           [sequelize.Sequelize.fn('date_format', sequelize.Sequelize.col('col_name'), '%d %b %y'), 'col_name']
                            ]}.then(function(result))
                             { // dateformate=04 Nov 2017
console.log(result)
}

Example 2: time sequelize html example stack overflow

attributes:{include:[[sequelize.cast(sequelize.col('dob'), 'VARCHAR') , 'dob']],exclude:['dob']}

Example 3: time sequelize html example stack overflow

const Test = sequelize.define('test', {
                // attributes
                name: {
                    type: DataType.STRING,
                    allowNull: false
                },
                createdAt: {
                    type: DataType.DATE,
     //note here this is the guy that you are looking for                   
                  get() {
                        return moment(this.getDataValue('createdAt')).format('DD/MM/YYYY h:mm:ss');
                    }
                },
                updatedAt: {
                    type: DataType.DATE,
                    get() {
                        return moment(this.getDataValue('updatedAt')).format('DD/MM/YYYY h:mm:ss');
                    }
                }

Tags:

Misc Example