Skip to content

Add PHP_BUILD_DATE constant #16747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ PHPAPI ZEND_COLD void php_print_info(int flag)
php_info_print_box_end();
php_info_print_table_start();
php_info_print_table_row(2, "System", ZSTR_VAL(php_uname));
php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__);
php_info_print_table_row(2, "Build Date", php_build_date);
#ifdef PHP_BUILD_SYSTEM
php_info_print_table_row(2, "Build System", PHP_BUILD_SYSTEM);
#endif
Expand Down
6 changes: 4 additions & 2 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ PHPAPI size_t core_globals_offset;

#define SAFE_FILENAME(f) ((f)?(f):"-")

const char php_build_date[] = __DATE__ " " __TIME__;

PHPAPI const char *php_version(void)
{
return PHP_VERSION;
Expand All @@ -110,8 +112,8 @@ PHPAPI unsigned int php_version_id(void)
PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
{
char *version_info;
spprintf(&version_info, 0, "PHP %s (%s) (built: %s %s) (%s)\nCopyright (c) The PHP Group\n%s%s",
PHP_VERSION, sapi_module->name, __DATE__, __TIME__,
spprintf(&version_info, 0, "PHP %s (%s) (built: %s) (%s)\nCopyright (c) The PHP Group\n%s%s",
PHP_VERSION, sapi_module->name, php_build_date,
#ifdef ZTS
"ZTS"
#else
Expand Down
7 changes: 7 additions & 0 deletions main/main.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
* @cvalue PHP_VERSION_ID
*/
const PHP_VERSION_ID = UNKNOWN;

/**
* @var string
* @cvalue php_build_date
*/
const PHP_BUILD_DATE = UNKNOWN;

/**
* @var bool
* @cvalue PHP_ZTS
Expand Down
3 changes: 2 additions & 1 deletion main/main_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions main/php.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ END_EXTERN_C()
extern char **environ;
#endif /* ifndef PHP_WIN32 */

extern const char php_build_date[];

#ifdef PHP_PWRITE_64
ssize_t pwrite(int, void *, size_t, off64_t);
#endif
Expand Down
8 changes: 8 additions & 0 deletions tests/basic/build_date.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
PHP_BUILD_DATE
--FILE--
<?php
var_dump(PHP_BUILD_DATE);
?>
--EXPECTREGEX--
string\(20\) "[A-Za-z]{3} \d{2} \d{4} \d{2}:\d{2}:\d{2}"