<?php
$winter = new DateTime('2010-12-21', new DateTimeZone('America/New_York'));
$summer = new DateTime('2008-06-21', new DateTimeZone('America/New_York'));

echo $winter->getOffset() . "\n";
echo $summer->getOffset() . "\n";
?>

<?php
$winter = date_create('2010-12-21', timezone_open('America/New_York'));
$summer = date_create('2008-06-21', timezone_open('America/New_York'));

echo date_offset_get($winter) . "\n";
echo date_offset_get($summer) . "\n";
?>


輸出:

-18000
-14400
Note: -18000 = -5 hours, -14400 = -4 hours.

文章標籤
全站熱搜
創作者介紹
創作者 stockwfj3 的頭像
stockwfj3

程式設計@筆記

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