Skip to content

Instantly share code, notes, and snippets.

@cs278
Created September 24, 2011 23:32
Show Gist options
  • Save cs278/1239997 to your computer and use it in GitHub Desktop.
Save cs278/1239997 to your computer and use it in GitHub Desktop.
chris@kinslayer:~/projects/phpbb/phpbb3 (develop-olympus) $ php -r 'date_default_timezone_set("Asia/Tokyo"); var_dump(gmdate("c"), date("c", gmdate("U") - date("Z")));'
string(25) "2011-09-24T23:31:48+00:00"
string(25) "2011-09-24T23:31:48+09:00"
chris@kinslayer:~/projects/phpbb/phpbb3 (develop-olympus) $ php -r 'date_default_timezone_set("Pacific/Auckland"); var_dump(gmdate("c"), date("c", gmdate("U") - date("Z")));'
string(25) "2011-09-24T23:31:59+00:00"
string(25) "2011-09-24T22:31:59+12:00"
1) phpbb_wrapper_gmgetdate_test::test_tz with data set #204 ('Antarctica/McMurdo')
--- Expected
+++ Actual
@@ @@
-2011-09-24 23:39:30
+2011-09-24 22:39:30
2) phpbb_wrapper_gmgetdate_test::test_tz with data set #207 ('Antarctica/South_Pole')
--- Expected
+++ Actual
@@ @@
-2011-09-24 23:39:30
+2011-09-24 22:39:30
3) phpbb_wrapper_gmgetdate_test::test_tz with data set #376 ('Pacific/Auckland')
--- Expected
+++ Actual
@@ @@
-2011-09-24 23:39:31
+2011-09-24 22:39:31
4) phpbb_wrapper_gmgetdate_test::test_tz with data set #377 ('Pacific/Chatham')
--- Expected
+++ Actual
@@ @@
-2011-09-24 23:39:31
+2011-09-24 22:39:31
<?php
public function provider_tz()
{
$tzs = array_map(function($tz)
{
return array($tz);
}, DateTimeZone::listIdentifiers());
return $tzs;
}
/**
* @dataProvider provider_tz
*/
public function test_tz($timezone)
{
date_default_timezone_set($timezone);
$this->assertSame(gmdate('Y-m-d H:i:s'), date("Y-m-d H:i:s", gmdate("U") - date("Z")));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment