将Unix/Linux时间转换为Windows时间的方法

nel*_*aro 3 linux windows datetime ms-office

我想要很多方法在两个系统上进行转换.我正在寻找一种快速简便的方法来做到这一点.

我想要Python方式,excel,openoffice calc方式,访问方式,命令行方式.你做任何其他方式也会很好.走另一条路(从Windows到Linux)也不错

我从我的一些脚本输出,包括自1970年以来的秒数,但我想转换为Windows时间.因此,当它被导入数据库时​​,它不会搞乱时间.

在Linux中,您可以使用gettimeofday从1970年1月1日起以微秒(10 ^ -6秒)为单位获得时间.

在Windows中包含一个64位值,表示自1601年1月1日(UTC)以来100纳秒间隔的数量.

这是一种C方式.将Unix/Linux时间转换为Windows FILETIME

来自find的示例

find ./sd-mmc-card/ -iname *.jpg -printf "%h/%f\t%f\t%a\t%Ax\t%AT\t%A@\n" > dbtime.txt

./sd-mmc-card/0117.jpg    0117.jpg    Thu Mar 24 15:27:25.0059226867 2011    24/03/2011    15:27:25.0592268670    1300973245.0592268670
Run Code Online (Sandbox Code Playgroud)

gra*_*ity 9

这在将time_t值转换为文件时间中进行了描述,该文件时间提供了示例C代码.

摘要:

filetime = (unixtime * 10000000) + 116444736000000000

0x3DE43B0C ? 0x01C295C4:91150E00 (2002-11-27 03:25:00 +0000)
Run Code Online (Sandbox Code Playgroud)

(同样有用的是如何从很长的路程中识别不同类型的时间戳.)


通常%AF %AT,使用strptime()或类似地解析人类可读的时间戳(例如"2002-11-27 03:25:00"(printf )更容易.