forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrentTime.php
More file actions
24 lines (19 loc) · 776 Bytes
/
currentTime.php
File metadata and controls
24 lines (19 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?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 ) );
}
}