• How PHP gmdate() function will work

    Following function is similar in nearly all respects to date() . It displays a date in a format specified in the first argument, except that the date string is calculated to be displayed in GMT.

    gmdate() function will have Format a GMT/UTC date/time.


    string gmdate ( string $format [, int $timestamp = time() ] )
    Format: The format of the outputed date string. See the formatting options for the date() function.
    Timestamp : The optional timestamp parameter is an integer Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time().
    Return Values:
    Function will return a formatted date string. If a non-numeric value will be used for timestamp than FALSE will be returned and an E_WARNING level error will be appeared.


    echo date("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 2013));
    echo gmdate("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 2013));


    First line will print “Jan 01 2013 00:00:00″
    Second line will print “Dec 31 2012 23:00:00″

    gmdate() function is of more use when combined with mktime() or gmmktime() than when using a static date string. Dates and times can be displayed in any order and combination, with any delimiters.

Comments on this post

Leave a Reply

  • Security Code :

    5 − = four