Date
and Time
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Taipei
須重新啟動 server 。
date_default_timezone_set($timezone_identifier)
動態設定時區<?php date_default_timezone_set('Asia/Taipei');?>
<p>現在時刻: <?php echo date('Y/m/d h:i:s a \a\t e');?></p>
<?php
const Date_aID='Y/m/d h:i:s a \a\t e';
$da1=new DateTime;
printf('<p>現在時刻: %s</p>',$d1->format(Date_aID));
?>
<?php
echo '<ol>';
$da2=new DateTime('2013/1/4');
$da3=new DateTime('+10 day');
$da4=new DateTime('2013/1/14 +1 year');
printf('<li>%s</li>',$da2->format(DateTime::W3C));
printf('<li>%s</li>',$da3->format(DateTime::W3C));
printf('<li>%s</li>',$da4->format(DateTime::W3C));
echo '</ol>';
?>
更新日期: