Automatic Copyright Year Using PHP

You can get Automatic Copyright Year Using PHP with the help of the date() function. The date function returns the current year if we set it's format parameter as 'Y'.

Table of Contents

PHP Date Function

PHP date() function returns the current date and time of the server as a string. Date function can have two parameters, the syntax of date function is given below.

<?php
date(format, timestamp);
?>

The format parameter is required and it defines the specific format of the output date string from date() function.

The timestamp parameter is optional and it specifies an integer Unix timestamp, default value is current server or local time.

Code

To get current year using date() function we will set it's format parameter as 'Y', Capital 'Y' means a four digit representation of a year. Small 'y' means two digit representation of current year.

<?php
echo "Copyright @ ".date("Y");
?>

Output

Copyright @ Current Year

In this way the value of year will always be dynamic and it will change automaitcally with every passing year.