Question:
I have a copyright statement on my site that contains the current year. When the next year arrives, how can I have the copyright date ranges change automatically?
Answer:
If you are willing to “hard code” your starting copyright year (that is, you already need to cover multiple years with a fixed starting date), you can do this easily with the EE {current_time} tag:
Content © Copyright 2004 - {current_time format="%Y"}
Otherwise, use PHP inside of an ExpressionEngine template as follows:
<?
$startyear = 2004;
$currentyear = date("Y");
if ($startyear == $currentyear)
{
echo "<div align=center>Content © $startyear - Your Name</div>\n";
}
else
{
echo "<div align=center>Content © $startyear - $currentyear - YourName</div>\n";
}
?>
You set your start date of your website, and then the current year is calculated. Depending on the values that are set, you’ll either see a single date or a date range.
You’ll need to turn on PHP in the template that contains this code. Consult the EE documentation on how to do this.
