close

 

<?php
$date = date_create('2000-01-01', timezone_open('Pacific/Nauru'));
echo date_format($date, 'Y-m-d H:i:sP') . "\n";

date_timezone_set($date, timezone_open('Pacific/Chatham'));
echo date_format($date, 'Y-m-d H:i:sP') . "\n";
?>
輸出:

2000-01-01 00:00:00+12:00
2000-01-01 01:45:00+13:45


<?php
$date = date_create('now', new DateTimeZone('Asia/Taipei'));
date_timezone_set($date, new DateTimeZone('Pacific/Nauru'));
echo timezone_name_get(date_timezone_get($date)) . "\n";

$date = new DateTime('now', new DateTimeZone('Asia/Taipei'));
$date->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $date->getTimezone()->getName() . "\n";

?>

輸出:
Pacific/Nauru
Pacific/Chatham

arrow
arrow
    全站熱搜

    stockwfj3 發表在 痞客邦 留言(0) 人氣()