Show Current Year Using Only Visualforce

August 17, 2009 · Filed Under Tips and Tricks, salesforce.com 

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 &copy; 2005-<script type="text/javascript">document.write(new Date().getFullYear());</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 &copy; 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!

Comments

2 Tweets

One Response to “Show Current Year Using Only Visualforce”

  1. pauloveryjr on August 18th, 2009 19:44

    RT @dschach: New x2od blog post: Show Current Year Using Only Visualforce http://bit.ly/F8tKf

    This comment was originally posted on Twitter

Leave a Reply




Additional comments powered by BackType