久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php如何設(shè)置系統(tǒng)時(shí)間

      php設(shè)置系統(tǒng)時(shí)間的方法:1、找到“date.timezone”配置項(xiàng),設(shè)置希望的默認(rèn)時(shí)區(qū);2、使用“date_default_timezone_set”函數(shù)設(shè)置一個(gè)腳本中所有日期時(shí)間函數(shù)所使用的默認(rèn)時(shí)區(qū)。

      php如何設(shè)置系統(tǒng)時(shí)間

      推薦:《PHP視頻教程》

      系統(tǒng)時(shí)區(qū)設(shè)置

      對(duì)日期時(shí)間進(jìn)行操作是很常見(jiàn)的編程任務(wù),但在進(jìn)行操作之前,我們應(yīng)該確保時(shí)區(qū)的一致性,即要操作的日期時(shí)間值所用時(shí)區(qū)與 PHP 日期時(shí)間函數(shù)所用的默認(rèn)時(shí)區(qū)應(yīng)是一致的,否則得到的結(jié)果不會(huì)是我們期望的。在 PHP 中,設(shè)置系統(tǒng)默認(rèn)時(shí)區(qū)有多種方式,下面我們逐一介紹:

      方式一:修改 php.ini 配置文件

      找到 date.timezone 配置項(xiàng),去掉前面的分號(hào),設(shè)置希望的默認(rèn)時(shí)區(qū)。

      修改前:

      [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone =

      修改后:

      [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Asia/Shanghai

      方式二:date_default_timezone_set() 函數(shù)

      用于設(shè)置一個(gè)腳本中所有日期時(shí)間函數(shù)所使用的默認(rèn)時(shí)區(qū)。

      語(yǔ)法

      date_default_timezone_set( string $timezone_identifier) : bool

      示例

      <?php $timezone = date_default_timezone_get();           // 獲取默認(rèn)時(shí)區(qū) echo 'default timezone is ', $timezone, "n"; if ($timezone !== 'Asia/Shanghai') {     date_default_timezone_set('Asia/Shanghai');    // 設(shè)置默認(rèn)時(shí)區(qū)  } echo 'current timezone is ', date_default_timezone_get(), "n"; ?>

      方式三:ini_set() 函數(shù)

      用于在運(yùn)行時(shí)修改某個(gè) php.ini 配置值。

      語(yǔ)法

      ini_set( string $varname, string $newvalue) : string

      示例

      <?php echo 'date_default_timezone_get return ', date_default_timezone_get(), "n";  $timezone = ini_get('date.timezone');           // 獲取默認(rèn)時(shí)區(qū)配置選項(xiàng)設(shè)置 echo 'date.timezone = ', $timezone, "n"; if ($timezone !== 'Asia/Shanghai') {     ini_set('date.timezone', 'Asia/Shanghai');  // 設(shè)置默認(rèn)時(shí)區(qū) } echo 'date.timezone = ', ini_get('date.timezone'), "n";  echo 'date_default_timezone_get return ', date_default_timezone_get(), "n"; ?>

      結(jié)語(yǔ)

      方法一屬于全局設(shè)置,對(duì)所有腳本生效,方法二、三只對(duì)所在腳本生效。通常,推薦使用 date_default_timezone_set() 函數(shù)來(lái)設(shè)置默認(rèn)時(shí)區(qū)。此外,在新的程序中,不應(yīng)再使用 Asia/Chongqing、PRC 這些不被推薦的時(shí)區(qū)標(biāo)識(shí)。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)