Posted By

Jeroen on 04/22/11


Tagged

auto copyright notice updating


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Jeroen


Auto updating copyright notice


 / Published in: PHP
 

A lot of websites are victim of outdated copyright notices, 2008, 2009 even 2000.

This function is designed to combat this annoyance, resulting in proper copyright notices. With valid years, and also valid Typography, separating the dates with an En dash and using character entities.

Using this function in your footer will create an output string similar as:

2008–2011 © for $startYear = 2008

2011 © if the $startYear is equal(or bigger) compared to the current year, note that if an invalid date(higher) is passed as the argument the function will still return the current year

Our company 2011 © for $startYear = "Our company" (not advised)

2009–2011 © Our company for $startYear = 2009 and $txt = "Our company" (advised)

  1. // Author: Jeroen Ransijn
  2. // Auto updating copyright notice
  3. function auto_copyright_notice($startYear,$txt) {
  4. // this line will compare the startYear with the current year, if this is the same only display the startYear
  5. // if this is false, both show: $startYear 'en dash(Study Typography you nerd!)' $currentYear
  6. // note that if $starYear is bigger then the current year,
  7. // or isn't an integer this function will still return the current year
  8. $year = ($startYear >= date("Y") ? date("Y") : $startYear . "–". date("Y"));
  9. return $year . " © " . $txt;
  10. }

Report this snippet  

You need to login to post a comment.