In this code snippet, I will show you how to display the copyright year using PHP automatically.To display the current year for copyright notices use the following code snippet:

Copyright © <?php echo date("Y") ?>

<?php echo date("Y") ?> will display the current year.

If you want to also display the start year, the code snippet will be:

Copyright © 2001-<?php echo date("Y") ?>

The following code snippet will display the current year only or start year with current year – you can choose, and is with error protection:

<?php function display_copyright($year = 'auto'){ ?>
   <?php if(intval($year) == 'auto'){ $year = date('Y'); } ?>
   <?php if(intval($year) == date('Y')){ echo intval($year); } ?>
   <?php if(intval($year) < date('Y')){ echo intval($year) . ' - ' . date('Y'); } ?>
   <?php if(intval($year) > date('Y')){ echo date('Y'); } ?>
<?php } ?>

Now to display the current year only for the above code snippet use the following:

<?php display_copyright(); ?>

Or to display the start year with the current year, use the following code snippet:

<?php display_copyright('2001'); ?>