PHP gmdate () function

Source: Internet
Author: User

Definition and Usage

The Gmdate () function formats the GMT/UTC date/time.

Similar to the date () function, the difference is that the time returned is Greenwich Mean Time (GMT).

Grammar
Parameters Description
Format Optional. Specifies how the results are returned.
Timestamp Optional.
Hints and notes

Note: Before PHP 5.1.0, negative timestamps (dates before 1970) do not work under some systems (for example, Windows).

ExampleExample 1

When the following program is run in China (GMT +0800), the first line shows "Jan 01 2000 00:00:00" and the second line shows "Dec 31 1999 16:00:00".

<?phpecho date ("M D y h:i:s", Mktime (0,0,0,1,1,2000)), Echo gmdate ("M D y h:i:s", Mktime (0,0,0,1,1,2000));? >

Output:

Jan 00:00:00dec 31 1999 16:00:00
Example 2
<?phpecho ("Result with date (): <br/>"); Echo (Date ("L"). "<br/>"); Echo (Date ("L DS \of F Y h:i:s A"). "<br/>"); Echo ("Oct 3,1975 is on a". Date ("L", Mktime (0,0,0,10,3,1975)). " <br/> "); Echo (Date (date_rfc822). "<br/>"); Echo (Date (Date_atom,mktime (0,0,0,10,3,1975)). "<br/><br/>"); Echo ("Result with Gmdate (): <br/>"); Echo (Gmdate ("L"). "<br/>"); Echo (Gmdate ("L DS \of F Y h:i:s A"). "<br/>"); Echo ("Oct 3,1975 is on a". Gmdate ("L", Mktime (0,0,0,10,3,1975)). " <br/> "); Echo (Gmdate (date_rfc822). "<br/>"); Echo (Gmdate (Date_atom,mktime (0,0,0,10,3,1975)). "<br/>");? >

Output:

Result with date (): Tuesdaytuesday 24th of January 2006 02:41:22 Pmoct 3,1975 is on a fridaytue, Jan 2006 14:41:22 CET1 975-10-03t00:00:00+0100result with Gmdate (): Tuesdaytuesday 24th of January 2006 01:41:22 Pmoct 3,1975 is on a ThursdayTue , Jan 2006 13:41:22 gmt1975-10-02t23:00:00+0000

PHP gmdate () function

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.