Print A Current Copyright Notice With PHP

17th June 2008 - 2 minutes read time

One thing that is inexcusable on any website is printing a copyright notice that is out of date. There are many protagonists of this crime and it is fairly easy to spot.

However, rather than go through all of the pages on your site and hand code in the copyright notice you could just put in the following little bit of PHP.

Copyright <?php echo date("Y"); ?> #! code

This will print off a current copyright notice, no matter what the year is.

Copyright 2008 #! code

The date() function is built into PHP and takes two parameters. The first (required) parameter is a format string for the date. In this example we are giving a single capital "Y", which returns a numeric representation of the year with 4 digits.

The second parameter for the date() function is optional and is the timestamp that you would like to be formatted. If no timestamp is given then the current timestamp is used.

Add new comment

The content of this field is kept private and will not be shown publicly.