Before PHP 8.5 version, obtaining the build date and time of the PHP binary required using the phpinfo function. This approach was cumbersome because the phpinfo prints its output directly to standard output, forcing the caller to capture and parse the text manually.
Since PHP 8.5, the PHP_BUILD_DATE constant can be used to retrieve the date and time when the PHP binary was built.
<?php
echo PHP_BUILD_DATE; // example: Nov 19 2025 09:58:52
The value of the PHP_BUILD_DATE constant uses M j Y H:i:s format, and it can be easily parsed with built-in PHP functions.
<?php
$dateTime = DateTime::createFromFormat('M j Y H:i:s', PHP_BUILD_DATE);
echo $dateTime->format('Y-m-d H:i:s'); // example: 2025-11-19 09:58:52
Leave a Comment
Cancel reply