Is it possible in php to get server php version release date?
So let's say I've got php 5.3.28.
Than something like phpdate() should return 11 Jul 2013.
You mean Build Date?
function phpdate($format="d M Y")
{
ob_start(); phpinfo(1);
if(preg_match('~Build Date (?:=> )?\K.*~', strip_tags(ob_get_clean()), $out))
return date($format, strtotime($out[0]));
}
echo phpdate();
04 Mar 2013
Test at eval.in (link expires soon)
Update: To get the actual release date on Linux, could match phpversion() in the changelog:
// match phpversion() in changelog
function phpReleaseDate()
{
$log = `zgrep '^[0-9].*PHP' /usr/share/doc/php5/changelog.gz`;
$ver = preg_replace('/^\d+\.\d+\.\d+\K.*/', "", phpversion());
$find = '/^(\d{2} [A-Z][a-z]{2} \d{4}), PHP ('.preg_quote($ver).')/';
if(preg_match($find, $log, $out))
return array('ver' => $out[2], 'date' => $out[1]);
}
print_r(phpReleaseDate());
Array ( [ver] => 5.3.3 [date] => 22 Jul 2010 )
Tried this with Debian Linux.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With