Return to Snippet

Revision: 31277
at May 19, 2011 06:50 by stephcode


Updated Code
For full year (four digits):

JS:

today=new Date();
y0=today.getFullYear();

HTML:

<p>&copy; <script type="text/javascript">document.write(y0);</script> Somecompany, Inc. All Rights reserved.</p>

- - - - -

For partial year (last two digits):

JS:

var foo = (new Date().getFullYear()).toString();
	// Contains last two characters of the full year.
	// ex: 2003 evaluates to 03.
	var bar = foo.substring(foo.length, 2);

HTML:

<p>All contents &trade; and &copy; 2005-<script type="text/javascript">document.write(bar);</script> Somecompany, Inc. unless otherwise noted herein. All rights reserved.</p>

Revision: 31276
at May 19, 2011 06:50 by stephcode


Updated Code
For full year (four digits):

JS:

today=new Date();
y0=today.getFullYear();

HTML:

<p>&copy; <script type="text/javascript">document.write(y0);</script> Somecompany, Inc. All Rights reserved.</p>

- - - - -

For partial year (last two digits):

JS:

var foo = (new Date().getFullYear()).toString();
	// Contains last two characters of the full year.
	// ex: 2003 evaluates to 03.
	var bar = foo.substring(foo.length, 2);

HTML:

<p>All contents &trade; and &copy; 2009-<script type="text/javascript">document.write(bar);</script> Somecompany unless otherwise noted herein. All rights reserved.</p>

Revision: 31275
at September 2, 2010 05:33 by stephcode


Initial Code
<head><script src="js/date/date-update.js" type="text/javascript"></script></head>

File: date-update.js

today=new Date();
y0=today.getFullYear();

<body><script type="text/javascript" src="js/date/date-update-do.js"></script></body>

File: date-update-do.js

document.write(y0);

Initial URL


Initial Description


Initial Title
Year update for full (four digit) year or last two digits, with JavaScript

Initial Tags
date

Initial Language
JavaScript