• Home
  • About
    • Leadership
    • Partners
    • Blogroll
  • Force-Squared Blog
    • Tips and Tricks
    • Configuration
    • Development
  • Support
    • Knowledge Base
    • Submit a Case
  • Is It Dreamforce Yet?

X-Squared On Demand

Salesforce solutions delivered

  • Home
  • About
    • Leadership
    • Partners
    • Blogroll
  • Force-Squared Blog
    • Tips and Tricks
    • Configuration
    • Development
  • Support
    • Knowledge Base
    • Submit a Case
  • Is It Dreamforce Yet?
  • Tips and Tricks
  • Configuration
  • Development
You are here: Home / Salesforce CRM / Tips and Tricks / Show Current Year Using Only Visualforce

Show Current Year Using Only Visualforce

August 17, 2009 by David Schach 1 Comment

While perusing some websites, looking at html code, I saw something interesting: A company had used Javascript to update the copyright date of its website using Javascript. This is the code.
Copyright © 2005-<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3Edocument.write(new%20Date().getFullYear())%3B%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<script>" title="<script>" /> This Company. All rights reserved.
Of course, as a Force.com developer, I prefer to use Visualforce and Apex over Javascript (as it makes the client thinner - thick clients are not my preferred modus operandi). This is the Visualforce version of the above code; it requires no Apex controller nor extension, and will always display the current year.
Copyright © 2005-{!year(today())} This Company. All rights reserved.
Feel free to use this snippet in your Visualforce pages (including Sites) to ensure that on January 1, you won't look foolish for failing to (shudder) manually update the footer in your site template. Happy coding!

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to email a link to a friend (Opens in new window) Email

Related

Filed Under: Tips and Tricks, Visualforce Tagged With: Visualforce

← Overload Apex Class to be Controller AND Extension Preparing a New Org →

Comments

  1. Tim says

    July 4, 2016 at 05:54

    My footer does as you suggest… but I thought to read up on it just now:

    It seems that you don’t need a year on a copyright statement as any content always gets life+70 years, regardless of whether it has a copyright statement. The statement is useful though as it states clearly that you own the content.

    Adding the current year may not be helpful: if someone looks at a stolen copy of your content alongside your content, your content may look like the stolen one as it will be dated the current year.

    http://stackoverflow.com/questions/2390230/do-copyright-dates-need-to-be-updated

    Reply

Share Your ThoughtsCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Find Us Online

  • Twitter
  • Facebook
  • LinkedIn
  • RSS

Subscribe

RSS Feed Comments

Subscribe via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 164 other subscribers

Copyright © 2008–2025 X-Squared On Demand · Genesis Framework by StudioPress · WordPress · Log in