为什么时间戳限制为2038? [英] Why do timestamps have a limit to 2038?

查看:1529
本文介绍了为什么时间戳限制为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位纪元计数,但目前它们之间相距甚远.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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