note 78570 modified in ref.datetime by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 02:21:05 +0000 |
| Subject: | note 78570 modified in ref.datetime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141953@lists.php.net to get a copy of this message | ||
Not really elegant, but tells you, if your installed timezonedb is the most recent:
<?php
class TestDateTimeTimezonedbVersion extends PHPUnit_Framework_TestCase
{
public function testTimezonedbIsMostRecent()
{
ini_set( 'date.timezone', 'Europe/Berlin' );
ob_start();
phpinfo(INFO_MODULES);
$info = ob_get_contents();
ob_end_clean();
$start = strpos( $info, 'Timezone Database Version' ) + 29;
$this->assertTrue( FALSE !== $start, 'Seems there is no timezone DB installed'
);
$end = strpos( $info, "\n", $start );
$installedVersion = substr( $info, $start, $end - $start );
exec( 'pecl remote-info timezonedb', &$output );
$availableVersion = substr( $output[2], 12 );
$this->assertEquals( $availableVersion, $installedVersion,
'The installed timezonedb is not actual. Installed: '.$installedVersion
.' available: '.$availableVersion
);
}
}
?>
--was--
Not really elegant, but tells you, if your installed timezonedb is the most recent:
class TestDateTimeTimezonedbVersion extends PHPUnit_Framework_TestCase
{
public function testTimezonedbIsMostRecent()
{
ini_set( 'date.timezone', 'Europe/Berlin' );
ob_start();
phpinfo(INFO_MODULES);
$info = ob_get_contents();
ob_end_clean();
$start = strpos( $info, 'Timezone Database Version' ) + 29;
$this->assertTrue( FALSE !== $start, 'Seems there is no timezone DB installed'
);
$end = strpos( $info, "\n", $start );
$installedVersion = substr( $info, $start, $end - $start );
exec( 'pecl remote-info timezonedb', &$output );
$availableVersion = substr( $output[2], 12 );
$this->assertEquals( $availableVersion, $installedVersion,
'The installed timezonedb is not actual. Installed: '.$installedVersion
.' available: '.$availableVersion
);
}
}
http://php.net/manual/en/ref.datetime.php