如何获取根据夏令时进行调整的当前时间?

发布于 2025-01-15 03:05:14 字数 189 浏览 0 评论 0原文

关于获取当前时间有很多问题,但它们对我不起作用

常见的答案是执行以下操作:datetime.datetime.now(pytz.timezone('EST'))

该解决方案不考虑夏令时。现在显示的是晚上 11 点,而实际上应该是中午 12 点。

如何在 python 中获取当前时间并考虑夏令时?

there are lots of questions about getting the current time, but they're not working for me

A common answer is to do the following: datetime.datetime.now(pytz.timezone('EST'))

This solution does not account for daylight savings. It shows now as 11pm when it should be 12pm.

How do I get the current time in python AND account for daylight savings?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文