Tip Details Add a Related Tip

Rate as: Positive Negative

Copyright date on sites

If you have your site, you probably have a copyright notice at the bottom of every page. Included in this notice is usually a year. Some people indicate the year the content started up to the current year, others just indicate the current year. If you have a notice like this, it's very convenient to just type in the current year. But then when the year changes, you need to update all of your templates (or even worse, all of your pages) to show the new year. Naturally nobody does this on New Year's Eve, so for some period of time your site has the wrong year listed.

There's an easy way around this. Instead of entering the year, put in code that will calculate the current year instead. This way you never need to update your copyright notice as the years roll by.

If you are using PHP with the Smarty templating system, here is an example of how you'd create a copyright notice that changes years automatically:

Copyright © 2007 - { $smarty.now|date_format:"%Y" } My Company, Inc.

If you are using PHP but not Smarty, you should be using Smarty :), you can also do this directly in the PHP like so:

Copyright © 2007 - <?php echo date('Y'); ?> My Company, Inc.

In both these cases, we are just getting the current date and then formatting so that only the year is shown. If you are using some other language, there is almost certainly a way in which you can get the current date, and a way to format this date. So while the specifics will vary somewhat, you can still use this approach to create a copyright notice that updates the year automatically.
Rating: 100% positive, 1 Vote
Categories: web programming php Smarty
Added: on Mar 11, 2008 at 8:14 am
Added By: an anonymous user

Comments on this Tip

Add a Comment
There are no comments for this tip
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

Using functions in conditionals in Smarty

Categories: php programming Smarty web
100% positive, 3 comments - last added on May 21, 2008 at 1:36 pm
– Tip added by rlansky on Aug 10, 2007 at 1:02 pm

Something to consider before switching platforms

100% positive, 0 comments
– Tip added by an anonymous user on Sep 25, 2007 at 7:31 pm

Redirecting in PHP

100% positive, 0 comments
– Tip added by an anonymous user 6 days, 21 hours ago

Static variables in Javascript

100% positive, 2 comments - last added on May 08, 2008 at 4:19 pm
– Tip added by an anonymous user on Aug 03, 2007 at 4:19 pm

How to Find a Random Date in PHP

33% positive, 0 comments
– Tip added by Walkere on Feb 07, 2008 at 8:25 pm

Detecting if a variable exists in Javascript

100% positive, 0 comments
– Tip added by an anonymous user 1 day, 20 hours ago

compressing javascript

100% positive, 0 comments
– Tip added by an anonymous user on Jun 12, 2008 at 3:02 pm

Telling when an iframe is done loading

100% positive, 0 comments
– Tip added by an anonymous user on Apr 18, 2008 at 8:05 am

How to Syndicate an RSS Feed On Your Site

100% positive, 0 comments
– Tip added by Walkere on Feb 09, 2008 at 5:48 pm

How to Send E-Mail in PHP: A “Share This” Form

50% positive, 0 comments
– Tip added by Walkere on Feb 06, 2008 at 6:45 pm

How to Create a Random Password in PHP

100% positive, 0 comments
– Tip added by Walkere on Feb 03, 2008 at 9:14 am

Javascript variable naming

100% positive, 1 comment - last added 1 day, 20 hours ago
– Tip added by an anonymous user on Sep 30, 2007 at 7:28 am

Avoiding facebook timeout errors

Categories: Facebook programming web
100% positive, 0 comments
– Tip added by an anonymous user on Aug 21, 2007 at 5:21 pm

Answering a tricky interview question on swapping

100% positive, 1 comment - last added on Aug 20, 2007 at 8:55 am
– Tip added by an anonymous user on Aug 20, 2007 at 7:26 am

Learn Python in 10 minutes

Categories: programming Python web
100% positive, 0 comments
– Tip added by Marcos84 on Jul 20, 2007 at 7:42 am

Referencing methods in PHP usort

Categories: php coding programming
no ratings, 0 comments
– Tip added by an anonymous user on Jun 13, 2008 at 11:18 am

CakePHP: Working with Associations

no ratings, 0 comments
– Tip added by an anonymous user on May 08, 2008 at 4:09 am

Code for creating Javascript CSS charts

no ratings, 0 comments
– Tip added by an anonymous user on Aug 21, 2007 at 12:23 pm

Efficient building of large strings in Javascript

no ratings, 0 comments
– Tip added by an anonymous user on Aug 08, 2007 at 12:52 pm

Avoid invalid title names when opening javascript windows

no ratings, 0 comments
– Tip added by an anonymous user on Aug 07, 2007 at 9:36 am