python - 日期时间到文件时间 (Python)

标签 python datetime filetime

是否有使用 python 将日期时间转换为文件时间的链接?

示例:2011 年 4 月 13 日 07:21:01.0874 (UTC) FILETIME=[57D8C920:01CBF9AB]

从电子邮件标题中获取上述内容。

最佳答案

我在重复问题中的回答被删除了,所以我会在这里发布:
四处冲浪我发现了这个链接:http://cboard.cprogramming.com/windows-programming/85330-hex-time-filetime.html

之后,一切都变得简单了:

>>> ft = "57D8C920:01CBF9AB"
... # switch parts
... h2, h1 = [int(h, base=16) for h in ft.split(':')]
... # rebuild
... ft_dec = struct.unpack('>Q', struct.pack('>LL', h1, h2))[0]
... ft_dec
... 129471528618740000L
... # use function from iceaway's comment
... print filetime_to_dt(ft_dec)
2011-04-13 07:21:01

调整它由您决定。

关于python - 日期时间到文件时间 (Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6408077/

相关文章:

python - [每个全局] 按键声音 (linux)

vba - 用毫秒获取文件的最后修改日期?

PHP 文件修改时间使用 GMT 偏移设置来报告正确的时间

python - 将日期时间转换回 Windows 64 位 FILETIME

sql - 从 View 中的字符串转换日期和/或时间时转换失败

php - MySQL查询以选择比x天新的记录

python - 如何重新采样时间增量?

python - Fabric 2.0.1 env 的替代品是什么?

python - 获取完整的原始 http 请求(包含 header 和正文)

asp.net - 从字符串 "31/03/2012"到类型 'Date' 的转换无效