如何将十六进制的时间室dword值转换为人类可读格式?

发布于 2025-01-19 06:13:48 字数 167 浏览 1 评论 0原文

谁能解释如何将十六进制的时间室dword值转换为人类可读格式?

我只是对诸如0x62444db4之类的价值如何转换为 “ 2022年3月30日,星期三,下午10:31:48”

我当然尝试了谷歌搜索,但找不到任何解释。但是有在线转换器可用。

但是我只是对自己转换这些价值观感兴趣。

Can anyone explain how to convert a Hex TimeDateStamp DWORD value into human readable format?

I'm just curious as to how a value such as 0x62444DB4 is converted into
"Wednesday, 30 March 2022 10:31:48 PM"

I tried googling of course and could not find any explanation. But there are online converters available.

But I'm just interested in converting these values for myself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2025-01-26 06:13:48

您的价值是32位时间戳。

您的DateTime值是32位UNIX时间戳:1970年1月1日以来的秒数。
请参阅 https://unixtime.org/

在大多数编程语言中,您可以直接使用hexadecimal note。
由于很多工程都参与其中,因此不应单独实施实施。 leap年,甚至leap秒,时区,日光节省时间,UTC ...使用时间戳时所有这些都需要解决。
我在下面添加了粗略的计算作为演示。绝对使用现有软件包或库与时间戳一起使用。

有关演示,请参见下面的JavaScript代码。
在那里,我将您的值乘以1000,因为JavaScript以毫秒为单位。但是否则,这适用于其他系统。

let timestamp = 0x62444DB4;
let dateTime = new Date(timestamp * 1000);
console.log('Timestamp in seconds:', timestamp);
console.log('Human-Readable:', dateTime.toDateString() + ' ' + dateTime.toTimeString());

// Rough output, just for the time.
// Year month and day get really messy with timezones, leap years, etc.
let hours = Math.floor(timestamp/3600) % 24;
let minutes = Math.floor(timestamp/60) % 60;
let seconds = Math.floor(timestamp) % 60;
console.log('Using our own time calculation:', hours + ':' + minutes + ':' + seconds);

Your value is a 32-bit Timestamp.

Your datetime value is a 32-bit Unix Timestamp: The number of seconds since 1/1/1970.
See https://unixtime.org/

In most programming languages you can work with the hexadecimal notation directly.
Implementation should not be done by one person alone, since a lot of engineering goes into it. Leap years, even leap seconds, timezones, daylight savings time, UTC... all these things need to be addressed when working with a timestamp.
I have added my rough calculation below as a demonstration. Definitely use an existing package or library to work with timestamps.

See the JavaScript code below for demonstration.
There I multiply your value by 1000 because JavaScript works in Milliseconds. But otherwise this applies the same to other systems.

let timestamp = 0x62444DB4;
let dateTime = new Date(timestamp * 1000);
console.log('Timestamp in seconds:', timestamp);
console.log('Human-Readable:', dateTime.toDateString() + ' ' + dateTime.toTimeString());

// Rough output, just for the time.
// Year month and day get really messy with timezones, leap years, etc.
let hours = Math.floor(timestamp/3600) % 24;
let minutes = Math.floor(timestamp/60) % 60;
let seconds = Math.floor(timestamp) % 60;
console.log('Using our own time calculation:', hours + ':' + minutes + ':' + seconds);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文