PowerShell 与 JavaScript 的时间起点
PowerShell 的时间起点是 1601年1月1日
JavaScript 的时间起点是 1970年1月1日
JavaScript 中的 new Date().getTime() 得到的数为经过的毫秒数
PowerShell 中的 ToFileTime() 得到的数为经过的时间数,单位为 100 纳秒,
是 Coordinated Universal Time 时间。
如果需要进行两者的换算,可以这样:
先算出 PS 与 JS 两者的起点差:[datetime]"1970-01-01" - [datetime]"1601-1-1"= 134774 天
PS 中获得当前的时间:$a = [system.datetime]::Now.AddDays(-134774).ToFileTimeUtc() /10000
从网页上找一个时间值:$b = 1483012731370
$c = ($a - $b) / 100068.4404260253906
前后相差 68 。