Date and Time in PHP

date() function is used in PHP to get date in date and time format.

Syntax
date(format,timestamp)

Format: Specifies the date format.
Timestamp : is optional part of date function.It is a sequence of characters, denoting the date and/or time at which a certain event occurred.
Commonly used character in date function.

d – Used for the day of the month (01 to 31)
m – Used for a month (01 to 12)
Y – Used for a year (in four digits)
l (lowercase ‘L’) – Represents the day of the week

and for date format used some character like : “/”, “.”, or “-”

Example
<?php
echo "Today Date " . date("Y.m.d") . "<br>";
echo "Today Date " . date("Y/m/d") . "<br>";
echo "Today Date " . date("Y-m-d") . "<br>";
echo "Today Date" . date("l");
?>

Leave a Reply

Your email address will not be published. Required fields are marked *