# Year 2038 issue

- Thread: https://externals.io/message/127671
- Original archive: https://news-web.php.net/php.internals/127671
- Started by Marc Bennewitz on 2025-06-16T13:01:00+00:00
- Messages: 14
- RFC: Big Integer Support (Withdrawn) — https://externals.io/rfc/bigint.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #127671 — Marc Bennewitz — 2025-06-16T13:01:00+00:00

URL: https://externals.io/message/127671#127671

Hi all,

It's 12.5 years only until the timestamps in PHP on 32bit will not work 
as expected anymore.

The DateTime[Immutable] classes use 64bit integers internally already 
but there are still a couple of places where this is an issue in the API 
due to PHP integer limit:

Based on that I personally would start to deprecate some of the 
functions and point to the OOP API and allow floating point values as 
timestamps.

* `date()` -> DEPRECATE: Use DateTimeImmutable instead
* `gmdate()` -> DEPRECATE: Use DateTimeImmutable instead
* `getdate()` -> DEPRECATE: Use DateTimeImmutable instead
* `mktime()` -> DEPRECATE: Use DateTimeImmutable instead
* `gmmktime()` -> DEPRECATE: Use DateTimeImmutable instead
* `idate()` -> DEPRECATE: Use DateTimeImmutable instead
* `localtime()` -> DEPRECATE: Use DateTimeImmutable instead
* `strtotime()` -> DEPRECATE: Use DateTimeImmutable instead
* `date_sun_info()` -> Support timestamp argument as float
* `time()` -> Allow to return floating point value if out-of-range
* DateTime[Immutable]::getTimestamp() -> Allow to return floating point 
value if out-of-range
* DateTime[Immutable]::setTimestamp() -> Support timestamp argument as float
* DateTimeZone::getTransitions() -> Support arguments as float and allow 
resulting transition timestamp as float if out-of-range

Alternatively, zend_long could be migrated to int64_t or arbitrary 
integers like proposed by Andrea Faulds back in 2014 [1].

What do you think?

[1] https://wiki.php.net/rfc/bigint

---

## #127675 — Alain D D Williams — 2025-06-16T13:53:09+00:00

URL: https://externals.io/message/127671#127675 · In reply to: #127671

> Alternatively, zend_long could be migrated to int64_t or arbitrary integers
> like proposed by Andrea Faulds back in 2014
>

> What do you think?
> 
https://wiki.php.net/rfc/bigint

+1

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  https://www.phcomp.co.uk/
Parliament Hill Computers. Registration Information: https://www.phcomp.co.uk/Contact.html
#include <std_disclaimer.h

---

## #127676 — Kamil Tekiela — 2025-06-16T14:16:10+00:00

URL: https://externals.io/message/127671#127676 · In reply to: #127671

Why do you say that these functions do not work with year 2038?
https://3v4l.org/61VLh

I wouldn't be opposed to deprecating them, but I don't know if we have
a good enough reason to do so.

---

## #127678 — Wim Godden — 2025-06-16T14:22:37+00:00

URL: https://externals.io/message/127671#127678 · In reply to: #127676

Including the EOL versions on that link shows that this occurs on < 
5.2.6 only


> Why do you say that these functions do not work with year 2038?
> https://3v4l.org/61VLh
>
> I wouldn't be opposed to deprecating them, but I don't know if we have
> a good enough reason to do so.

---

## #127679 — Marc Bennewitz — 2025-06-16T14:30:22+00:00

URL: https://externals.io/message/127671#127679 · In reply to: #127676

> Why do you say that these functions do not work with year 2038?
> https://3v4l.org/61VLh
>
> I wouldn't be opposed to deprecating them, but I don't know if we have
> a good enough reason to do so.
>
https://3v4l.org seems to be 64bit now ;) -> https://3v4l.org/1FX4E

I get this:
$ ./sapi/cli/php y2038.php

Warning: `mktime()`: Epoch doesn't fit in a PHP integer in 
/home/mbennewitz/workspace/php-src/y2038.php on line 2
Jan 01 1970 00:00:00
Warning: `mktime()`: Epoch doesn't fit in a PHP integer in 
/home/mbennewitz/workspace/php-src/y2038.php on line 3
Jan 01 1970 00:00:00

---

## #127681 — Kamil Tekiela — 2025-06-16T14:50:33+00:00

URL: https://externals.io/message/127671#127681 · In reply to: #127679

If you use 32bit version of PHP then of course you will run into this
problem. But 32bit versions are used infrequently now, and this is a
known limitation. As far as I know, these functions have no issues
with year 2038 in 64bit. My point is that these functions work fine
and the fact that 32bit is limited isn't a very good reason to
deprecate them. If anything, it's a reason to deprecate 32bit
versions.

Future dates aren't an alien concept. Applications must already
account for the year 2038 problem today. PHP has handled this issue a
long time ago. If PHP users who use the 32bit version are not ok with
this limitation, then they must make an effort to migrate to 64bit
architecture.

---

## #127682 — drealecs@gmail.com — 2025-06-16T14:54:12+00:00

URL: https://externals.io/message/127671#127682 · In reply to: #127671

> Hi all,
>
> It's 12.5 years only until the timestamps in PHP on 32bit will not work
> as expected anymore.
>
>
>
Hi,

I think that maybe we can already deprecate supporting 32 bit builds.
And, maybe with PHP 9, or PHP 10, or with a future version that might exist
in about 6/7 years, completely drop 32 bits support.

As far as I checked a bit, all major OSs where PHP could run already
dropped or will drop support for 32 bits builds.
I expect that at some point even the linux kernel will drop support.

The impacted runtimes will probably be very low.

-- 
Alex

---

## #127684 — Rob Landers — 2025-06-16T15:21:31+00:00

URL: https://externals.io/message/127671#127684 · In reply to: #127682

> 
> 
> > […]
> 
> Hi,
> 
> I think that maybe we can already deprecate supporting 32 bit builds.
> And, maybe with PHP 9, or PHP 10, or with a future version that might exist in about 6/7 years, completely drop 32 bits support.
> 
> As far as I checked a bit, all major OSs where PHP could run already dropped or will drop support for 32 bits builds.
> I expect that at some point even the linux kernel will drop support.
> 
> The impacted runtimes will probably be very low.
> 
> -- 
> Alex
> 

100% agree. We are already running out of space on some bitmasks (there are a couple with exactly one bit left, or even none in the case of GC flags) for 32 bit support.

— Rob

---

## #127687 — Yogarine — 2025-06-16T17:01:52+00:00

URL: https://externals.io/message/127671#127687 · In reply to: #127684

Hi all,


> 
> 
> 
> 
> > […]
> 
> 100% agree. We are already running out of space on some bitmasks (there are a couple with exactly one bit left, or even none in the case of GC flags) for 32 bit support.
> 
> — Rob

I'm reminded of a recent comment by Derick. He mentioned that usually if a function can't be provided on a specific platform or SAPI, that function is disabled for that environment specifically. This allows for a polyfill to provide an alternative implementation. (e.g. `getallheaders()`)

Considering 32-bit builds will not be able to reliable provide the `date()` function at some point, what if we deprecate, and later disable, these integer date functions on 32-bit builds specifically? This would have 0 impact for 64-bit users and provide a means for users on legacy or embedded systems to use an alternative implementation (that perhaps uses a custom Unix epoch, or numeric strings ¯\_(ツ)_/¯).

Alwin

---

## #127688 — Marc Bennewitz — 2025-06-16T17:23:45+00:00

URL: https://externals.io/message/127671#127688 · In reply to: #127684

>
>
> 
> > […]
>
> 100% agree. We are already running out of space on some bitmasks 
> (there are a couple with exactly one bit left, or even none in the 
> case of GC flags) for 32 bit support.

Dropping 32bit builds entirely is an option I would support as well.

Would you be able to help me writing an RFC for it as I don't have 
enough knowledge of PHP internals to know where 32bit build is going to 
be problematic there as well?

>
> — Rob

---

## #127705 — Marc Bennewitz — 2025-06-18T11:18:40+00:00

URL: https://externals.io/message/127671#127705 · In reply to: #127687

> Hi all,
>
> 
> > […]
> I'm reminded of a recent comment by Derick. He mentioned that usually if a function can't be provided on a specific platform or SAPI, that function is disabled for that environment specifically. This allows for a polyfill to provide an alternative implementation. (e.g. `getallheaders()`)
>
> Considering 32-bit builds will not be able to reliable provide the `date()` function at some point, what if we deprecate, and later disable, these integer date functions on 32-bit builds specifically? This would have 0 impact for 64-bit users and provide a means for users on legacy or embedded systems to use an alternative implementation (that perhaps uses a custom Unix epoch, or numeric strings ¯\_(ツ)_/¯).

It's a long list of date functions already (see my first mail) and on 
looking deeper into detail it's not limited to the date extension. Same 
issues happen on a wide range of standard functions like "filemtime" or 
"opcache_get_status". Specifically everywhere where a timestamp is 
involved. Not even talking about the already known behavior differences 
of functions like "crc32".

> Alwin

---

## #127709 — Rob Landers — 2025-06-18T12:58:23+00:00

URL: https://externals.io/message/127671#127709 · In reply to: #127705

> 
> 
> 
> > […]
> It's a long list of date functions already (see my first mail) and on looking deeper into detail it's not limited to the date extension. Same issues happen on a wide range of standard functions like "filemtime" or "opcache_get_status". Specifically everywhere where a timestamp is involved. Not even talking about the already known behavior differences of functions like "crc32".
> 
> 
> 
> > […]
> 
> *Attachments:*
>  • OpenPGP_0x3936ABF753BC88CE.asc
>  • OpenPGP_signature.asc

I dunno. The more I think about it, the more this seems like a systemic issue with 32-bit. Meaning this is potentially the wrong layer to try and fix it. This will likely have to be addressed at a deeper layer (such as the OS) or a higher layer (treating negative numbers differently than positive ones, contextually).

— Rob

---

## #127720 — Derick Rethans — 2025-06-19T12:39:32+00:00

URL: https://externals.io/message/127671#127720 · In reply to: #127682

> 
> 
> > […]
> 
> I think that maybe we can already deprecate supporting 32 bit builds. 
> And, maybe with PHP 9, or PHP 10, or with a future version that might 
> exist in about 6/7 years, completely drop 32 bits support.

FWIW, I dropped support for 32-bit PHP builds for Xdebug quite a while 
ago already:
https://github.com/xdebug/xdebug/commit/0a6df4d49ddb5a252628668661313e022941779a

I have not heard complaints.

cheers,
Derick

---

## #127723 — Derick Rethans — 2025-06-19T13:16:08+00:00

URL: https://externals.io/message/127671#127723 · In reply to: #127671

Hi,



> It's 12.5 years only until the timestamps in PHP on 32bit will not work as
> expected anymore.
> 
> The DateTime[Immutable] classes use 64bit integers internally already but
> there are still a couple of places where this is an issue in the API due to
> PHP integer limit:
> 
> Based on that I personally would start to deprecate some of the functions and
> point to the OOP API and allow floating point values as timestamps.

I think I would agree with deprecating the "really old" date time APIs 
as well, but not because of the 2038 problem. However, I also don't 
think we should deprecate these before there is a better Date/Time API 
in PHP which solves a few of the issues with the current Date/Time 
classes and methods. Although they handle the 2038 issue, there are 
obviously numerous issues with it (Immutable vs non-Immutable, or not 
having dedicated types for timezoned/local dates, and instants, for 
example).

cheers,
Derick
