PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




PHP gmdate() Function


Tutorials »Php »

Topic

What is a gmdate Function?
How to format GMT/UTC date and time?



Explanation

The "gmdate()" is used to format a GMT/UTC date and time.

Syntax:
    gmdate(format,timestamp)

In the above syntax the "format" is to specify how to return the results, 35 pre-defined formats are available. The "timestamp" is an optional field.

Example:
    <?php
    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 was 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 was 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 />");
    ?>
Result:
    Result with date():
    Tuesday
    Tuesday 24th of January 2006 02:41:22 PM
    Oct 3,1975 was on a Friday
    Tue, 24 Jan 2006 14:41:22 CET
    1975-10-03T00:00:00+0100

    Result with gmdate():
    Tuesday
    Tuesday 24th of January 2006 01:41:22 PM
    Oct 3,1975 was on a Thursday
    Tue, 24 Jan 2006 13:41:22 GMT
    1975-10-02T23:00:00+0000

In the above example, the date() return the value of the current timezone, whereas, gmdate() function returns the value for GMT timezone values.

Note: (PHP 4, PHP 5)






A Note

Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial. Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.

Other Links

web hosting