小编Jam*_*rke的帖子

如何在Python中获得UTC时间?

我在StackExchange上搜索了一堆解决方案,但没有什么是我需要的.在JavaScript中,我使用以下内容来计算自1970年1月1日以来的UTC时间:

function UtcNow() {
    var now = new Date();
    var utc = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds());
    return utc;
}
Run Code Online (Sandbox Code Playgroud)

什么是等效的Python代码?

python datetime

94
推荐指数
8
解决办法
16万
查看次数

标签 统计

datetime ×1

python ×1