php 日期時差8小時間解決方案_PHP教程

來源:互聯網
上載者:User
程式中添加時間的初始化語句:“date_default_timezone_set("asia/shanghai");

定義和用法

the date_default_timezone_set() function sets the default timezone used by all date/time functions.
date_default_timezone_set()函數的作用是:設定用於一個指令碼中所有日期時間函數的預設時區。

syntax
文法

date_default_timezone_set(timezone)

parameter
參數
description
描述
timezone required. the timezone identifier, like "utc" or "europe/paris". list of valid timezones: http://www.php教程.net/manual/en/timezones.php
必要參數,時區確認器,如“utc”或“europe/paris”。下面列出了有效時區:http://www.php.net/manual/en/timezones.php

tips教程 and notes
注意點

note: this function always returns true (even if the timezone parameter isn't valid).
注意:這個函數總是返回true(即使時區參數無效的情況下)。

example
案例

 

the output of the code above will be:
上述代碼將輸出下面的結果:

http://www.bkjia.com/PHPjc/632328.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632328.htmlTechArticle程式中添加時間的初始化語句:date_default_timezone_set(asia/shanghai); 定義和用法 the date_default_timezone_set() function sets the default timezone used by all d...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.