Date function of PHP

PHP date_timezone_set() function
PHP getdate() function

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)
ParameterDescription
formatRequired. Specifies the format of the outputted date string.
timestampOptional. Specifies an integer Unix timestamp. Default is the current local time (time())
PHP date() method
Fomats for the date() method
Constans for the date() method

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.

PHP date_timezone_set() function
PHP getdate() function
en English
X
Scroll to Top