PHP 8.5: New PHP_BUILD_DATE constant

Version8.5
TypeNew Feature

PHP 8.5 introduces a new PHP constant named PHP_BUILD_DATE that is assigned the time and date the PHP binary is built.

PHP already includes constants like PHP_VERSION and PHP_VERSION_ID that expose the version information about the PHP binary being run.

However, the Build date/time was previously only available from the phpinfo function. Extracting the build date and time from the phpinfo function is unwieldy because it directly prints the text to the standard output, and the caller has to collect this information and parse it. To make it worse, depending on whether phpinfo is run in CLI or not, phpinfo prints text in plain-text or HTML.

With the new PHP_BUILD_DATE constant, the build date and time is directly accessible.

echo PHP_BUILD_DATE;
// Sep 16 2025 10:44:26

PHP_BUILD_DATE Date and Time format

The date and time assigned to the PHP_BUILD_DATE constant is in PHP's M j Y H:i:s format.

Note that the date of the month (j) is space-prefixed if the date of the month is fewer than 10. For example, PHP builds on September 3rd will have PHP_BUILD_DATE value Sep 3 2025 10:44:26.

This value can be parsed to a DateTimeImmutable object as shown below:

$dt = DateTimeImmutable::createFromFormat('M j Y H:i:s', PHP_BUILD_DATE);
$dt->format('U'); // Unix timestamp, e.g. "1758019466"
$dt->format('Y-M-d'); // "2025-Sep-16"

Backward Compatibility Impact

The PHP_BUILD_DATE constant is a new constant added in PHP 8.5. Unless a PHP application declares a constant with an identical name in the global namespace, this change does not cause any backward-compatibility issues.

On previous PHP versions, although cumbersome, the same value can be extracted from the phpinfo output:

ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_clean();

preg_match('@Build Date(?:( => | </td><td class="v">))(?<buildtime>[A-Za-z]{3} (?: \d|\d\d) \d{4} \d{2}:\d{2}:\d{2})@', $info, $matches);

echo $matches['buildtime']; // Sep 16 2025 10:44:26

PHP_BUILD_DATE Implementation