PHP code example of letraceursnork / copyright-year-range

1. Go to this page and download the library: Download letraceursnork/copyright-year-range library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

letraceursnork / copyright-year-range example snippets


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

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

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"