PHP date function

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


6 points

The PHP date() function formats a timestamp to a more readable date and time. But, what is a timestamp?



8 points

A timestamp is the number of seconds from January 1, 1970 at 00:00. Otherwise known as the Unix Timestamp, this measurement is a widely used standard that PHP has chosen to utilize.

The required format parameter in the date() function specifies how to format the date/time.

* d - Represents the day of the month (01 to 31)
* m - Represents a month (01 to 12)
* Y - Represents a year (in four digits)


<?php
echo date("Y/m/d") . "<br />";
echo 
date("Y.m.d") . "<br />";
echo 
date("Y-m-d")
?> 

2010/04/04
2010.04.04
2010-04-04 

Anonymous's picture
Created by Anonymous

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.