总是插入UTC DateTime

发布于 2025-02-12 03:07:56 字数 211 浏览 1 评论 0原文

我使用使用 sqlite3 方言,并且在插入方面有问题 日期数据类型。每当我尝试调用model.create() 即使我使用“ new Date()”或默认的“(dateTime(现在','localtime')”,“我更喜欢我有时区控制或至少关注我的本地机器时区。

运行在节点V16^上

I using Sequelize with sqlite3 dialect and I having problem with inserting
DATE datatype. Sequelize always default "+0:00" whenever I tried to call model.create()
to a table even though I used "new Date()" or default "(DATETIME('NOW', 'LOCALTIME')" in column default. I would prefer I have time zone control or at least follow my local machine timezone.

Running on Node v16^

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不在是我 2025-02-19 03:07:56

作为最佳实践,最好不要将日期保存在数据库中,而无需时区域将日期保存在UTC中,并使用必要的逻辑直接从应用程序中应用。
这使您可以管理时区,并始终知道哪个是标准。

As best practices it would be better to have the dates saved in the database as utc without time zone and apply it directly from the application, with the necessary logic.
This allows you to manage the time zone and always know which is the standard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文