mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Previously, UTC context was implied, but could be unreliable due to being affected by plugins. Props Rarst, rahulsprajapati, marco.marsala. Fixes #37440. git-svn-id: https://develop.svn.wordpress.org/trunk@43594 602fd350-edb4-49c9-b593-d223f7449a82
25 lines
776 B
PHP
25 lines
776 B
PHP
<?php
|
|
|
|
/**
|
|
* @group date
|
|
* @group datetime
|
|
*/
|
|
class Tests_Date_CurrentTime extends WP_UnitTestCase {
|
|
|
|
public function test_should_work_with_changed_timezone() {
|
|
|
|
$format = 'Y-m-d H:i:s';
|
|
$timezone_string = 'America/Regina';
|
|
update_option( 'timezone_string', $timezone_string );
|
|
$datetime = new DateTime( 'now', new DateTimeZone( $timezone_string ) );
|
|
|
|
date_default_timezone_set( $timezone_string );
|
|
$this->assertEquals( gmdate( $format ), current_time( $format, true ) );
|
|
$this->assertEquals( $datetime->format( $format ), current_time( $format ) );
|
|
|
|
date_default_timezone_set( 'UTC' );
|
|
$this->assertEquals( gmdate( $format ), current_time( $format, true ) );
|
|
$this->assertEquals( $datetime->format( $format ), current_time( $format ) );
|
|
}
|
|
}
|