HOME | SERVICES | CONTACT | PORTFOLIO | MUSIC

Update Copyright in Javascript and Coldfusion

Although you only have to do it once a year, keeping the copyright updated on your web site(s) can sometimes be troublesome... The best thing to do would be to automate the process.. Here are two ways you can accomplish this. 1. Javascript:


<script language="JavaScript">
var d=new Date();
yr=d.getFullYear();
if (yr!=2003)
     document.write("- "+yr);
</script>
2. Coldfusion: First Set the date the site was created:

<CFSET createdYear = DateFormat('1/1/2001', 'yyyy')>
The Get the current Year:

<CFSET currentYear = DateFormat(now(), 'yyyy')>
Then determine if the createdYear and the currentYear are different and output the copyright:

<CFOUTPUT>
© #createdYear#
<!--- if the createdYear and currentYear are different then show both years --->
<CFIF createdYear neq currentYear>
- #currentYear#
</CFIF>
</CFOUTPUT>
Your site Name.
There ya go!! Enjoy

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Content Copyright © 2005 Owen Consulting - All Rights Reserved | This Blog Powered by BlogCFC version 5.9.1.002.