In this article, you will learn about the date function of PHP – date() method. The PHP date() method returns the local date and time as a formatted string.
What is the syntax of the date() function in PHP?
date(format, timestamp)
Parameter | Description |
---|---|
format | Required. Specifies the format of the outputted date string. |
timestamp | Optional. Specifies an integer Unix timestamp. Default is the current local time (time()) |
Example of the date() function
Example 1. In this example, we simply print the day and then print the day, date, month, year, time, AM or PM.
<?php
echo date("l");
echo date("l jS \of F Y h:i:s A");
?>
Read more about the Date function in the reference on the official PHP site.