2024-05-23 16:47:52 发布
网友
unix timestamp是一个int,它给出了自1970年1月1日(UTC)以来的秒数。在
int
有没有一种方法可以使用python将.NET时间戳转换为unix时间戳?或者只能用C语言完成吗? 任何帮助都将不胜感激。在
类似的问题:How to convert a Unix timestamp to DateTime and vice versa?这包含了如何在C中实现这一点,我正在寻找在Python34中实现这一点的方法
Is there a way to convert the .NET timestamp to unix timestamp using python?
posix_epoch_as_dotnet = 621355968000000000 # convert .NET timestamp to POSIX timestamp posix_timestamp = (130900894153614080 - posix_epoch_as_dotnet) // 10**7
很容易在以UTC表示时间的datetime对象和时间戳之间进行转换:
以及背面:
posix_timestamp = (utc_time - posix_epoch) // timedelta(seconds=1) dotnet_timestamp = 10 * (utc_time - dotnet_epoch) // timedelta(microseconds=1)
见^{} function on how to implement ^{} on older Python versions。在
很容易在以UTC表示时间的datetime对象和时间戳之间进行转换:
^{pr2}$以及背面:
见^{} function on how to implement ^{} on older Python versions 。在
相关问题 更多 >
编程相关推荐