Why do timestamps have a limit to 2038?

后端 未结 4 1829
-上瘾入骨i
-上瘾入骨i 2020-11-30 05:59

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 tim

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 06:07

    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
    

    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.

提交回复
热议问题