没有什么好说的了,直接上代码吧:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/**
* 太平洋时间转北京时间
*/
public function pacificToPRC( $time = '' ){
date_default_timezone_set( 'Pacific/Apia' );
if ( empty ( $time )){
$time = time();
}
date_default_timezone_set( 'Asia/Shanghai' );
$date = date ( 'Y-m-d H:i:s' , $time );
$time = strtotime ( $date );
return $time ;
}
/**
* 北京时间转太平洋时间
* @param unknown_type $time
*/
public function PRCToPacific( $time = '' ){
if ( empty ( $time )){
date_default_timezone_set( 'Asia/Shanghai' );
$time = time();
}
date_default_timezone_set( 'Pacific/Apia' );
$date = date ( 'Y-m-d H:i:s' , $time );
$time = strtotime ( $date );
return $time ;
}
|