PHP

Display current copyright year

What does this snippet do?

This PHP snippet dynamically generates a copyright notice that displays a starting year and the current year. If both years are the same, it shows only one year; otherwise, it shows a range (e.g., "1995 - 2025").

PHP
<?php
  $startYear = 1995; 
  $currentYear = date("Y"); 

if ($startYear == $currentYear) {
  $yearDisplay = $startYear;
  } else {
  $yearDisplay = "$startYear - $currentYear";
  }

$copyrightContent = "&copy; Company ($yearDisplay)";
?>