问题描述
我们需要按特定格式而不是默认格式安排返回日期.据我所知,没有办法通过选项或任何其他方式进行设置.缺少每次检索日期后都手动更新日期的功能,有人能够轻松解决此问题吗?还是我错过了什么?
We need to have sequelize return dates in a particular format, not the default one. As far as I can tell, there is no way to set that up in options, or any other way. Short of manually updating the dates every time after they are retrieved, anyone been able to solve this easily? Or am I missing something?
推荐答案
您可以定义自定义实例方法getDate/setDate,该方法将在sequelize内部表示形式和所需格式之间转换日期,例如 http://sequelize.readthedocs.org/en/latest/docs/models-definition/index.html (请参见模型扩展"部分)
you can define custom instance methods getDate/setDate which would translate date between sequelize internal representation and desired format like so http://sequelize.readthedocs.org/en/latest/docs/models-definition/index.html (see 'Expansion of models' section)
这篇关于有没有一种简单的方法可以使Sequelize以特定格式返回其日期/时间字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!