PHP Date() - Format the Date

This function format a local time/date. The required format parameter in the date() function specifies how to format the date/time. The date function uses letters of the alphabet to represent various parts of a typical date and time format.

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)

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: