Format GMT/UTC Date/time

Source: Internet
Author: User
Tags echo date php tutorial

PHP gmdate () function
PHP date/time function
Definitions 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 Standard (GMT).

Gmdate (Format,timestamp)
Parameter description
Format is optional. Specify how the results are returned.
Timestamp optional.
Tips and comments
Note: Before PHP 5.1.0, a negative timestamp (the date before 1970) does not work on some systems (for example, Windows).
Example 1
When running the following program in China (GMT +0800), the first line shows "01 2000 00:00:00", while the second line shows "Dec 31 1999 16:00:00".

<?php Tutorial
echo 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:

01 2000 00:00:00
Dec 31 1999 16:00:00
Example 2
Echo ("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_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 ():
Tuesday 24th of January 2006 02:41:22 PM
Oct 3,1975 is on a Friday
Tue, 2006 14:41:22 CET

Result with Gmdate ():
Tuesday 24th of January 2006 01:41:22 PM
Oct 3,1975 is on a Thursday
Tue , 2006 13:41:22 GMT

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: 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.