PHP Date Time Function | Coding Tag

PHP Date() / Time() Function


PHP Date Function is used to print date and PHP Time Function is used to print time. It will return the current date/time of the server.

PHP offers powerful tools to print date in your web page. This function makes manipulating dates simply. The date function uses letters of the alphabet to show various parts of a typical date format.

We will use letters in our first example, see below:

PHP Date Function Example:


echo date("m") . "<br />";
echo date("M") . "<br />";
echo date("y") . "<br />";
echo date("Y") . "<br />";
echo date("d") . "<br />";
echo date("D") . "<br />";



d: It shows the day of the month.

m: It shows the current month.

y: It shows the current year

echo . date("Y/m/d") . "<br>";
echo date("Y.m.d");

PHP Time Function:

The PHP time() function is used to return the current time as a UNIX timestamp. This function shows you all the information that you required about the present date and time.

It needs no arguments, but returns an integer value.

echo time();

D is used for Day (three letters), M is used for Month (three letters) and Y is used for year.

Want to know ? How to set default time zone in php

Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments