来自时间戳的时间值 [sqlite3, Knex]

普拉尚帕达杜尼

如何在 created_at 行中仅存储 HH:MM 等 IST 时间值,生成的值timestamp采用 UTC 和 DATE+TIME 格式

exports.up = function(knex) {
    return knex.schema.createTable('tbl_xyz', (table) => {
        table.increments('id').primary();
        table.timestamp('created_at').defaultTo(knex.fn.now());
        table.string('date');
        table.string('url');
        table.string('tags');
    });
};
蒙多

尝试date-fns

const dateFns = require("date-fns")

然后,在表 def 上:

table.timestamp('created_at').defaultTo(dateFns.format(knex.fn.now(), 'hh:mm'))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章