为什么时间戳限制为 2038?

编程入门 行业动态 更新时间:2024-10-20 07:54:21
本文介绍了为什么时间戳限制为 2038?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚刚在运行日历脚本时发现,PHP 中的时间戳限制为 2038.这到底是什么意思?为什么是 2038 而不是 2050 或 2039?如果时间戳只计算给定日期(1970 年)的秒数,为什么要限制?

I just found out, running a calendar script, that timestamps in PHP has a limit to 2038. What does it really mean? Why is it 2038 instead of 2050 or 2039? Why a limit if timestamps just count seconds from a given date (1970)?

推荐答案

限制是由大多数 C 库用于表示该计数的 4 字节有符号整数强加的.快速数学(假设 365 天年,不完全正确):

The limit is imposed by the 4 byte signed integers that most C libraries use for representing that count. Quick math (assumes 365 day years, not exactly correct):

2147483648 seconds ~ 68.1 years

这也意味着下限约为 1900.一些库已经开始引入 64 位 epoch 计数,但目前还很少.

This also implies a lower limit of ~1900. Some libraries have started to introduce 64 bit epoch counts, but they are few and far between for the moment.

更多推荐

为什么时间戳限制为 2038?

本文发布于:2023-11-25 15:32:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630314.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!