且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Excel 中将 Unix 纪元时间戳转换为人类可读的日期/时间?

更新时间:2022-12-18 09:37:58

是的,您可以创建一个公式来为您执行此操作.Java 和 Unix/Linux 计算自 1970 年 1 月 1 日以来的毫秒数,而 Microsoft Excel 在 Windows 的 1/1/1900 和 Mac OS X 的 1/1/1904 开始计算.您只需要执行以下操作即可转换:

Yes, you can create a formula to do this for you. Java and Unix/Linux count the number of milliseconds since 1/1/1970 while Microsoft Excel does it starting on 1/1/1900 for Windows and 1/1/1904 for Mac OS X. You would just need to do the following to convert:

Windows 上的 GMT 时间

For GMT time on Windows

=((x/1000)/86400)+(DATEVALUE("1-1-1970") - DATEVALUE("1-1-1900"))

Mac OS X 上的格林威治标准时间

For GMT time on Mac OS X

=((x/1000)/86400)+(DATEVALUE("1-1-1970") - DATEVALUE("1-1-1904"))

对于 Windows 上的本地时间(用您当前的 GMT 偏移量替换 t)

For local time on Windows (replace t with your current offset from GMT)

=(((x/1000)-(t*3600))/86400)+(DATEVALUE("1-1-1970") - DATEVALUE("1-1-1900"))

Mac OS X 上的当地时间(用您当前的 GMT 偏移量替换 t)

For local time on Mac OS X (replace t with your current offset from GMT)

=(((x/1000)-(t*3600))/86400)+(DATEVALUE("1-1-1970") - DATEVALUE("1-1-1904"))

在您的特定情况下,您似乎处于山区时间(格林威治标准时间偏移 7).因此,如果我将给定的 1362161251894 值粘贴到单元格 A1 的新 Excel 电子表格中,然后粘贴以下公式,我会得到 41333.46356 的结果,如果我然后告诉 Excel 将其格式化为日期(在单元格上按 ctrl+1)是:2/28/13 11:07 AM


In your specific case it looks like you are in a Mountain Time (GMT offset of 7). So if I paste your value given of 1362161251894 in a new Excel spreadsheet in cell A1 and then paste the following formula, I get a result of 41333.46356, which if I then tell Excel to format as a Date (press ctrl+1 on the cell) is: 2/28/13 11:07 AM

=(((A1/1000)-(7*3600))/86400)+(DATEVALUE("1-1-1970") - DATEVALUE("1-1-1900"))