How To: PHP to Display Current Year

An alternative method to using jQuery to display the current year would be to get the date server side with a language like PHP. If your web hosting can run PHP you can deploy the following PHP code to display the current year.

<?php echo date('Y'); ?>

Printing the current year on the page with a PHP script is commonly used to display a copyright year in the footer.

Current year isn’t the only format the PHP date() can display. Visit the date function page on php.net to see the other formatting parameters.