【问题标题】:python how tu get Coordinated Universal Time universal coordinate time? [duplicate]python如何获取Coordinated Universal Time 通用坐标时间? [复制]
【发布时间】:2021-07-29 09:30:48
【问题描述】:

我能够获得实际时间的 UTC 时间。 使用:

datetime.now

我需要获取不是本地的通用 UTC,这是时钟:https://time.is/es/UTC

【问题讨论】:

    标签: python time utc


    【解决方案1】:

    您实际上应该始终使用 .now() 与 UTC 时区

    import datetime
    datetime.datetime.now(tz=datetime.timezone.utc)
    

    参考comment on .utcnow() in the official docs

    这取自系统时钟,因此您需要确保在您的系统上配置了 NTP

    【讨论】:

    • 嗨!我需要的是通用坐标时间,现在是 3:52 你可以在这里查看time.is/es/UTC
    猜你喜欢
    • 2014-01-31
    • 1970-01-01
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 2017-10-01
    • 1970-01-01
    • 2020-06-08
    • 2013-03-19
    相关资源
    最近更新 更多