如何将微秒转换为时间戳?
我从未加密的 .DAT 文件中获取了这段代码:
Code:
00 e1 27 17 6f e6 69 c0
十进制转换为 63,374,851,375,000,000。该数字的单位是微秒。
而这个巨大的数字无法绕过 1st January 1970 00:00:00 格式;目前大多数转换器都使用这种格式。
所以,是的。是否有这样一个使用当年 1 月 1 日格式的转换器?或者我该如何制作一个?
顺便说一句,时间戳既是日期又是时间。
提前致谢!
I took this piece from an unencrypted .DAT file:
Code:
00 e1 27 17 6f e6 69 c0
Which translates to 63,374,851,375,000,000 in decimal. The units for the number are microseconds.
And this huge number cannot bypass the 1st January 1970 00:00:00 format; such a format that most converters use today.
So, yes. Is there such a converter that uses the 1st January of the year 1 format? Or how shall I make one?
And by the way, a timestamp is both date and time.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你没有说你使用的是什么语言,如果是.NET语言,可以使用: http://msdn.microsoft.com/en-us/library/z2xf7zzk.aspx 对于该构造函数,输入以纳秒为单位(您确定您的数字以毫秒为单位而不是以纳秒为单位吗? )。
如果您确定它以毫秒为单位,则转换为纳秒应该很容易:1 毫秒 = 1 000 000 纳秒。
但我感觉这些是纳秒而不是毫秒...
现在您已经告诉我们它的单位是微秒:
C# 从十进制到 yyyy 的示例 dd MM hh:mm:ss
它打印:
2009 20 02 02:49:35
相反,从 yyyy dd MM hh:mm:ss 到十进制
它打印:
63370694975000000
如果你想要十六进制,只需写:
那么它将打印:
E1234FB3278DC0
如果你想要另一个答案编程语言,请将其添加到您的问题中。
You do not say what language are you using, if it is a .NET language, you can use: http://msdn.microsoft.com/en-us/library/z2xf7zzk.aspx for that constructor the input is in nanoseconds (are you sure that your number is in milliseconds and not in nanoseconds?).
If you are sure it is in milliseconds, the conversion to nanoseconds should be easy: 1 millisecond = 1 000 000 nanoseconds.
But I have the feeling that those are nanoseconds and not milliseconds...
Now that you have told us that it is in microseconds:
C# Example from decimal to yyyy dd MM hh:mm:ss
It prints:
2009 20 02 02:49:35
The other way around from yyyy dd MM hh:mm:ss to decimal
It prints:
63370694975000000
And if you want it in hexadecimal just write:
Then it will print:
E1234FB3278DC0
If you want the answer in another programming language, please add that to you question.
在 JAVA 中要将微秒转换为
java.sql.Timestamp
:In JAVA in order to convert microseconds into
java.sql.Timestamp
:使用下面的 Java 代码将微秒转换为日期和时间,
这将返回,
2016-01-27 03:41:12
Use below Java code to covert microseconds to date and time,
Which will returns,
2016-01-27 03:41:12