如何在 Excel 中将 Unix 纪元时间戳转换为人类可读的日期/时间? [英] How do I convert a Unix epoch timestamp into a human readable date/time in Excel?

查看:45
本文介绍了如何在 Excel 中将 Unix 纪元时间戳转换为人类可读的日期/时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含来自 Java 应用程序的 Unix 纪元时间戳的 Excel 文档.我想看看它们转换成什么,并将它们表示为 Excel 中人类可读的日期.

I have Excel documents containing Unix epoch timestamps from a Java application. I'd like to see what they translate to and represent them as human readable dates inside of Excel.

例如,以下 long:1362161251894 应评估为可读的内容,例如:01 Mar 2013 11:07:31,894

For example, the following long: 1362161251894 should evaluate to something readable like: 01 Mar 2013 11:07:31,894

我假设我可以为此创建一个公式,但我不确定如何.谢谢!

I'm assuming I can create a formula for this, but I'm not sure how. Thanks!

推荐答案

是的,您可以创建一个公式来为您执行此操作.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"))

这篇关于如何在 Excel 中将 Unix 纪元时间戳转换为人类可读的日期/时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆