NameSilo

Automated Copyright Updater

Spaceship Spaceship
Watch

exponent

VIP Member
Impact
47
I was just tooling around for a way to make my pages auto update their years and put this little script together, thought it was pretty helpful so I figured I should post it. Originally I made this thinking that copyrights expired either 7 or 14 years, but after looking it up it actually looks like in the USA at the minimun they last 95 years and at the most it is 120 years, but this still works, but I guess it really is not needed though.

Place in head javascript section (change the two "95"'s to what ever time period you need and change c to the actual starting date of the content):

Code:
function yearSet(){
c=2007
cd=new Date()
y=cd.getYear()
 if(y<1000){
  y+=1900
 }
test=y-c
 if(test>95){
  update=(test-95)
  c=c+update
 }
 if(c==y){
  gop=y
 }else{
  gop=c+'-'+y
 }
 document.getElementById('year').innerHTML=gop
}

Place wherever your copyright stamp is to be displayed:

Code:
© Copyright <span id="year"></span>

Place at very end above the "/body" tag (or you can make this into a onload function)

Code:
<script language="javascript"><!--
yearSet()
//--></script>

Or if you rather just want a simple verision, place in head javascript section:

Code:
cd=new Date()
y=cd.getYear()
 if(y<1000){
  y+=1900
 }

Place wherever your copyright stamp is to be displayed (change the 2007 to what ever year needed, though if it is for the same year this will not work correctly because it will show the same year twice unless you remove the static hardcode, in which case next year you will need to put it back so this will make you work a little harded the other more complex code above does this for you):

Code:
© Copyright 2007-<script language="javascript"><!--
document.write(y)
//--></script>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back