Limitations of 32-bit PHP

Last updated on
26 October 2017

This page has not yet been reviewed by System requirements maintainer(s) and added to the menu.

If you run Drupal on a system where PHP is compiled or limited to using 32-bit integers, you will only be able to enter dates between 1901 and 2038 (specifically from 20:45:52 UTC on 13 December 1901 to 03:14:07 UTC on 19 January 2038).  This is commonly known as the 2038 bug.

The usual symptom is seeing a date displayed or recorded as 1970-01-01 instead of an intended value outside the above range. This will affect all PHP applications. In Drupal specifically, date-based field types are impacted, i.e. Date only and Date and Time, including the "Select list" widget. You can choose years outside the 1900 to 2038 range, but because PHP itself can't handle them, they will be stored/displayed as 1970-01-01 without warning.

Affected products:

- Windows users with PHP 5.x/7.x 32 bit and PHP 5.x 64bit until experimental.
- Acquia Dev Desktop 2 (as recently as Feb 1 2017 build)
- Any web stack package (XAMPP, Wamp, etc.) with PHP compiled for 32bit and/or running on a 32bit system.

Note: it's how PHP itself is compiled that counts: if you have a 32-bit version of PHP running in a 64-bit operating system you'll still experience the problem.

To test if your PHP is affected, you can run this command:

php -d date.timezone='UTC' -r '$date = new DateTime("2040-02-01"); echo $date->format("U") . PHP_EOL . gettype($date->getTimestamp()) . PHP_EOL . date("Y-m-d H:i:s", $date->format("U")) . PHP_EOL;'

An unaffected PHP instance should print:
2211667200
integer
2040-02-01 00:00:00

An affected PHP instance prints:
2211667200
boolean
1903-12-26 17:31:44

A new system requirement is being added to Drupal to warn users during installation.