PHP setup date_default_timezone_set () _php Tutorial

Source: Internet
Author: User
PHP Tutorial Set the Date_default_timezone_set function ()
Definition and usage
The Date_default_timezone_set () function sets the default time zone for all date/time functions used in the script.

Grammar
Date_default_timezone_set (TimeZone)

$now = time ();
Date_default_timezone_set (' america/new York ');
Print date (' C ', $now);
Date_default_timezone_set (' Europe/paris ');
Print date (' C ', $now);
?>

Look at one more example.

Date_default_timezone_set (' America/denver ');

$summer = Mktime (12,0,0,7,4,2008);
Print date (' C ', $summer). "N";

Date_default_timezone_set (' America/phoenix ');
Print date (' C ', $summer). "N";
?>

Note: since PHP 5.1.0 (This version of the date time function is rewritten), if the time zone is not a rule, each call to a DateTime function produces an E_notice level error message, and the e_strict level of information is generated if the system setting or the TZ environment variable is used.


Reference table

Table h-10. Others

CET cst6cdt Cuba Egypt
Eire est Est5edt etc/gmt etc/gmt+0
Etc/gmt+1 etc/gmt+10 etc/gmt+11 etc/gmt+12 etc/gmt+2
Etc/gmt+3 etc/gmt+4 etc/gmt+5 etc/gmt+6 etc/gmt+7
Etc/gmt+8 etc/gmt+9 etc/gmt-0 etc/gmt-1 etc/gmt-10
etc/gmt-11 etc/gmt-12 etc/gmt-13 etc/gmt-14 etc/gmt-2
Etc/gmt-3 etc/gmt-4 etc/gmt-5 etc/gmt-6 etc/gmt-7
Etc/gmt-8 etc/gmt-9 etc/gmt0 Etc/greenwich etc/uct
Etc/universal ETC/UTC Etc/zulu Factory GB
gb-eire GMT gmt+0 gmt-0 gmt0
Greenwich HONGKONG HST Iceland Iran
Israel Jamaica Japan Kwajalein Libya
Met MST MST7MDT Navajo NZ
Nz-chat Poland Portugal PRC PS Tutorial T8PDT
ROC rok Singapore Turkey UCT
Universal UTC W-su Wet Zulu

http://www.bkjia.com/PHPjc/632296.html www.bkjia.com true http://www.bkjia.com/PHPjc/632296.html techarticle The PHP tutorial sets the Date_default_timezone_set () definition and usage of the Date_default_timezone_set () function to set the default time zone for all date/time functions used in the script. Grammar ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.