letraceursnork/copyright-year-range

Lightweight PHP library to generate dynamic copyright year ranges

v1.0.0 2025-05-27 15:48 UTC

This package is auto-updated.

Last update: 2025-05-27 15:50:49 UTC


README

Coverage Status

A simple PHP utility for generating dynamic copyright year ranges in your projects.

Quick installation

composer require letraceursnork/copyright-year-range

Purpose

This package provides an easy way to format copyright years, automatically handling cases where the start year matches the current year. Instead of hardcoding dates like © 2020 - 2025, you can generate them dynamically, ensuring your copyright notices stay up to date. Forget about ifs like this:

if ($year !== '2024') { // The year that copyright starts
    echo "© 2024 - $year"
} else {
    echo "© $year";
}

Just use this:

echo CopyrightHelper::getCopyrightString(2020); // Output: "2020 - 2025" (if current year is 2025)
echo CopyrightHelper::getCopyrightString(2025); // Output: "2025" (if current year is 2025)

Custom formatting

CopyrightHelper::setFormat('%1$s – %2$s'); // Using an en dash  
echo CopyrightHelper::getCopyrightString(2020); // "2020 – 2023"  

CopyrightHelper::setFormat('%1$s <= = => %2$s');  
echo CopyrightHelper::getCopyrightString(2020); // "2020 <= = => 2023"  

Perfect For

  • Websites & web applications
  • Open-source projects
  • Documentation footers
  • Automatically updating copyright notices

Keep your copyright notices fresh with zero maintenance! 🚀