Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Php PHP Display date and time


Share on Google+Share on Google+

PHP Display date and time

In this tutorial you will learn how to display the time in PHP program.

PHP displaying the time and date into your timezone


For a lot of people, when they use the date() function in PHP, it doesn't display the correct time and date for their region, as their servers may be in a different part of the world to where they are. This simple bit of code uses the gmdate() function to overcome this little problem.

General description of gmdate() function is as follows:

General Format string gmdate(string $format [, int $timestamp] )
Parameters $format: the format of the date string $timestamp: Integer Unix timestamp
Return Value Returns the formatted date string

Example 1:


ECHO "<b>Date using date()fucntion is:</b>"."<br/>";

echo date("M d Y H:i:s",mktime(0,0,0,1,1,1998))."<br/>";

ECHO "<b>Date using gmdate()fucntion is:</b>"."<br/>";

echo gmdate("M d Y H:i:s",mktime(0,0,0,1,1,1998))."<br/>";



Date using date()fucntion is:
Jan 01 1998 00:00:00
Date using gmdate()fucntion is:
Jan 01 1998 00:00:00

Note: To know the date format in details please visit our web page:


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 9, 2009

Related Tutorials

Discuss: PHP Display date and time   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
March 21, 2012

how to create 5 digit secretkey using for loop in php