Php Date and Time

The PHP date() function formats a timestamp to a more readable date and time.

Get a Simple Date

The required format parameter of the date() function specifies how to format the date (or 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)
  • l (lowercase 'L') - Represents the day of the week
  • Example :-

    Automatic Copyright Year

    Use the date() function to automatically update the copyright year on your website:

    Example :-

    Result

    © 2010-2018

    Get a Simple Time

    Here are some characters that are commonly used for times:

  • h - 12-hour format of an hour with leading zeros (01 to 12)
  • i - Minutes with leading zeros (00 to 59)
  • s - Seconds with leading zeros (00 to 59)
  • a - Lowercase Ante meridiem and Post meridiem (am or pm)
  • Example :-

    Result

    The time is 03:56:58pm