13 Jan 2008

Is it still copyright 2007? If so, this is your friendly reminder to change it. Better yet, why not use a little bit of code that does it for you?

  1. Copyright ©
  2. < ?php // automatically update the copyright date each year
  3. ini_set('date.timezone', 'America/New_York');
  4. $startYear = 2000;
  5. $thisYear = date('Y');
  6. echo "{$startYear} - {$thisYear}";
  7. ?> all rights reserved

You can get a list of timezones from the PHP manual.

4 Comments

  1. No. 1 Dave Bowker 01/14/08

    That’s a little bloated for displaying the year. I’ve used a similar effect on all my sites…

    <?php echo date(’Y'); ?>

  2. No. 2 Jen 01/14/08

    Dave-Thanks for providing another way to do this. There are so many different methods for automating the date, I should have probably posted a few more.

  3. No. 3 Ian Ferguson 01/18/08

    Hey there! I realize that the supplied code snippet was meant to provide date ranges greater than $startYear; however, I think it’s still wise to account for $startYear being equal to $thisYear (2008–2008) — which would be redundant — as well as protect against any technical issues resolving the server’s timestamp (eg. 2008–1950).

    1. < ?php
    2. ini_set('date.timezone','America/New_York');
    3. echo (($thisYear=date('Y'))>($startYear=2000))?$startYear."–".$thisYear:$startYear;
    4. ?>
  4. No. 4 Jen 01/19/08

    Thanks for the tip, a much smarter way to handle it. I’m no PHP coding expert so sometimes I end up taking the long way around.

Tell Me What You Think

About Me

My name’s Jen; I’m a cynical, sarcastic, ex-drummer who is fond of dark humor. I've held way too many factory & retail jobs but finally found my calling one Christmas holiday in a dark, musty basement. I am now a CSS & XHTML web standards looney and can be found daily—when I’m not at my Mac—at the local fair-trade coffee shop buying an iced-soy mocha no matter the temperature.

I am also the owner of Pop Stalin Design specializing in CSS & XHTML web design as well as custom WordPress themes.