(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)
IntlCalendar::setTime — 設定日曆時間,以自 epoch 以來的毫秒數表示
物件導向風格
程序式風格
設定由此物件表示的瞬間時間。該瞬間時間由一個 浮點數 表示,其值應為自 epoch (1970 年 1 月 1 日 00:00:00.000 UTC) 以來的毫秒數(整數),忽略閏秒。所有欄位值將會相應地重新計算。
calendar
一個 IntlCalendar 實例。
timestamp
由該瞬間時間與 epoch 之間的毫秒數表示的瞬間時間,忽略閏秒。
範例 #1 IntlCalendar::setTime()
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'fr_FR');
$cal = new IntlGregorianCalendar(2013, 5 /* 五月 */, 1, 12, 0, 0);
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
/* 在歐洲/里斯本,2013-10-27 凌晨 02:00,時鐘會倒退一小時,
時區從 UTC+01 調整為 UTC+00 */
$cal->setTime(strtotime('2013-10-27 00:30:00 UTC') * 1000.);
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
$cal->setTime(strtotime('2013-10-27 01:30:00 UTC') * 1000.);
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
以上範例將輸出
samedi 1 juin 2013 12:00:00 heure avancée d’Europe de l’Ouest dimanche 27 octobre 2013 01:30:00 heure avancée d’Europe de l’Ouest dimanche 27 octobre 2013 01:30:00 heure normale d’Europe de l’Ouest