PHP 快速導覽 - 核心延伸函數 日期、時間相關 date_offset_get()

內建函數 (function) date_offset_get() 用來取得時間物件 (object) 與標準時區的時差

函數說明
int date_offset_get(DateTime $object)$object 為時間物件。


date_offset_get() 與 DateTime::getOffset() 有相同的功能,舉例如下
<?php
$date = date_create('now',  new DateTimeZone('Asia/Taipei'));
echo date_offset_get($date) . "\n";

$date = new DateTime('now',  new DateTimeZone('America/New_York'));
echo $date->getOffset() . "\n";

/* 《程式語言教學誌》的範例程式
    http://pydoing.blogspot.com/
    檔名:datetime18.php
    功能:示範 PHP 程式 
    作者:張凱慶
    時間:西元 2013 年 2 月 */
?>


執行結果如下



中英文術語對照
函數function
物件object


您可以繼續參考
日期、時間相關的類別與函數


相關目錄
回 PHP 快速導覽
回 PHP 教材
回首頁


參考資料
http://www.php.net/manual/en/function.date-offset-get.php
http://www.php.net/manual/en/datetime.getoffset.php

沒有留言: