Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Automated Copyright Updater

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch

exponent

VIP Member
Impact
48
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back