Monday, 22 August 2011

PHP Date() Function

PHP Date() Function

The PHP date() function is used to format a time and/or date.

PHP Date() - Format the Date

The required format parameter in the date() function specifies how to format the date/time.
Here are some characters that can be used:
  • d - Represents the day of the month (01 to 31)
  • m - Represents a month (01 to 12)
  • Y - Represents a year (in four digits)
A list of all the characters that can be used in the format parameter, can be found in our PHP Date reference.
Other characters, like"/", ".", or "-" can also be inserted between the letters to add additional formatting:

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

The output of the code above could be something like this:



No comments:

Post a Comment

Share on Tumblr