Home Tutorial Php PHP date function

 
 

Share on Google+Share on Google+
PHP date function
Posted on: January 18, 2010 at 12:00 AM
Advertisement
PHP Date() function is used to display the date and time in a précised format. With the help of PHP date function you can format timestamp to a more readable date and time.

PHP Date() Function

PHP Date() function is used to display the date and time in a précised format.  With the help of PHP date function you can format timestamp to a more readable date and time.

The following example shows you how to display to format date and time in different style :

Syntax :

date(format,timestamp)

format : It specifies in which styles you format the timestamp.

timestamp : It specifies the timestamp by default.

Example 1 :  How to get Current Date?

A. <?php echo date('y m d'); ?>

B. <?php echo date('Y M D'); ?>

C. <?php echo date('Y m d h: s: m'); ?>

d.  <?php echo date('m/d/y); ?>

e.  <?php echo date("D,F,jS"); ?>

f.    <?php echo date("l,F/jS/y"); ?>

The output of the above is : 

A. 10 01 18 :  (Year Month Date)

B. 2010 Jan Mon : (Year Month Date)

C. 2010 01 18 09: 47: 01 : (Year Month Date Time(hours seconds minutes))

d. 01/18/10

e. Mon,January,18th

f. Monday,January/18th/10

In the above example, you can see the differences, each and every date format is different. There are number of variety provided by PHP in date function.

Also, PHP provides number of functions to format the days & date . Lets see the syntax :

Syntax :

1.Number of Days in a Month    

  cal_days_in_month( CAL GREGORIAN, $intMonth, $intYear);

2. Check the Date Format

  checkdate ($intMonth,$date, $intYear);

Advertisement

Related Tags for PHP date function:


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: January 18, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com