Home Php PHP Display date and time
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

PHP Display date and time

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

<?php

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/>";

?>

Output:

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: http://www.roseindia.net/tutorial/php/phpdate/index.html

Advertisements

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

Ask Questions?    Discuss: PHP Display date and time   View All Comments

Post your Comment


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

how to create 5 digit secretkey using for loop in php
DMCA.com