Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: JavaScript
Expertise: Intermediate
Jun 2, 2003

Dynamically Change the Year in Your Source Code

This little bit of code is great for doing stuff like "COPYRIGHT 1998—(present year)." It saves Webmasters from having to cull through their source code looking for the year (every year on January 1st) to change it manually.

Here's an example:


© 1998 - <script language="JavaScript" type="text/javascript">
var today = new Date()
var year = today.getYear()
if (year < 1900)
{
year = year + 1900;
}
document.write(year)
</script> 
Donald Demrow
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date