Php sets the Beijing time function date_default_timezone_set ()

Source: Internet
Author: User
Tags datetime php tutorial

Set the Beijing time function date_default_timezone_set () in the php Tutorial ()
Definition and usage
The date_default_timezone_set () function is used to set the default time zone of all date/time functions in the script.

Syntax
Date_default_timezone_set (timezone)

<? Php
$ Now = time ();
Date_default_timezone_set ('America/new york ');
Print date ('C', $ now );
Date_default_timezone_set ('Europe/paris ');
Print date ('C', $ now );
?>

Let's look at another example.

<? Php

Date_default_timezone_set ('America/denver ');

$ Summer = mktime );
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 DATETIME function has been rewritten), if the time zone does not comply with the rules, every call to the DATETIME function will generate an e_notice-level error message, if you use system settings or tz environment variables, information at the e_strict level will also be generated.


Reference Table

Table H-10. others

Cet cst6cdt cuba eet egypt
Eire est est5edt 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/
Etc/GMT-3 etc/GMT-4 etc/GMT-5 etc/GMT-6 etc/GMT-7 etc/
Etc/GMT-8 etc/gmt-9 etc/gmt0 etc/greenwich etc/uct
Etc/universal etc/utc etc/zulu factory gb
Gb-eire 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 pstutorial t8pdt
Roc rok singapore turkey uct
Universal utc w-su wet zulu

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.