sequelize格式化时间
来源:互联网 发布:污网络用语是啥意思 编辑:程序博客网 时间:2024/06/06 00:35
在使用sequelize时碰到输出时间中带T和Z的情况,如何解决呢?
需要用到moment
首先使用npm安装moment:npm install --save moment
在项目中使用:
在初始化数据表时:
var Sequelize = require('sequelize');var moment = require('moment');var sequelize = require('./sequelize');var base = sequelize.define('base',{ base_one :{type:Sequelize.STRING}, base_two :{type:Sequelize.STRING}, createdAt: { type: Sequelize.DATE, get() { return moment(this.getDataValue('createdAt')).format('YYYY-MM-DD HH:mm:ss'); } }, updatedAt: { type: Sequelize.DATE, get() { return moment(this.getDataValue('updatedAt')).format('YYYY-MM-DD HH:mm:ss'); } }});//自动创建表sequelize.sync().then(function() { console.log("base");});module.exports = base;
输出数据时,使用moment将时间格式转化为YYYY-MM-DD HH:mm:ss格式
阅读全文
1 0
- sequelize格式化时间
- 格式化时间
- 格式化时间
- 时间格式化
- 格式化时间
- 时间格式化
- 格式化时间
- 格式化时间
- 格式化时间
- 格式化时间
- 格式化时间
- 时间格式化
- 时间格式化
- 格式化时间
- 时间格式化
- 时间格式化
- 时间格式化
- 时间格式化
- Linux reserved memory分析
- GIT 查看/修改用户名和邮箱地址 原创 2016年08月17日 13:36:39 标签:git 46999 用户名和邮箱地址的作用 用户名和邮箱地址是本地git客户端的一个变量,不随git库而改变
- cocos2d-x3.2 24种基本特效
- Retrofit 探索二:RxJava+Retrofit实现网络请求
- heartBleed漏洞检查python脚本
- sequelize格式化时间
- 第二部分Calendar原理和思想
- Vue学习日志:事件处理器(8)
- Ceres学习(四)
- 面向对象
- 对象内存管理
- strcpy、strncpy、memcpy的区别
- 继承
- 抽象类、接口