问题描述
我有一个包含来自Java应用程序的Unix历元时间戳的Excel文档。我想看看他们翻译的内容,并将其表示为Excel内的人类可读日期。例如,以下长: 1362161251894 应该评估可读的东西: 2013年3月1日11:07:31,894
我假设我可以为此创建一个公式,但我不知道如何。谢谢!
是的,你可以创建一个公式来为你做这个。 Java和Unix / Linux计算自1/1970以来的毫秒数,而Microsoft Excel从Windows的1/1/1900开始,Mac OS X为1/1/1904。您只需要执行以下操作:转换:
对于Windows上的GMT时间
=((x / 1000)/ 86400)+(DATEVALUE(1-1-1970) - DATEVALUE(1-1-1900))
对于Mac OS X上的GMT时间
=((x / 1000)/ 86400) +(DATEVALUE(1-1-1970) - DATEVALUE(1-1-1904))
对于Windows上的本地时间(用GMT替换当前的偏移量)
=(((x / 1000) - (t * 3600))/ 86400)+(DATEVALUE(1-1-1970) - DATEVALUE(1-1-1900))
对于Mac OS X上的本地时间(用GMT替换当前的偏移量)
=(((x / 1000) - (t * 3600))/ 86400)+(DATEVALUE(1-1-1970) - DATEVALUE(1-1-1904))
在您的具体情况下,它看起来如果你在山区时间(GMT偏移量 7 )。因此,如果我在单元格A1的新的Excel电子表格中粘贴了 1362161251894 的值,然后粘贴以下公式,则得到41333.46356的结果,如果我随后将Excel格式化为日期(在单元格上按ctrl + 1)是: 2/28/13 11:07 AM
=(((A1 / 1000) - (7 * 3600))/ 86400)+(DATEVALUE(1-1-1970) - DATEVALUE(1-1-1900))
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.
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!
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:
For GMT time on Windows
=((x/1000)/86400)+(DATEVALUE("1-1-1970") - DATEVALUE("1-1-1900"))
For GMT time on Mac OS X
=((x/1000)/86400)+(DATEVALUE("1-1-1970") - DATEVALUE("1-1-1904"))
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"))
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"))
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纪元时间戳转换为人类可读取的日期/时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!