Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Forked from anonymous/gist:665793
Created November 6, 2010 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotlolita/665802 to your computer and use it in GitHub Desktop.
Save robotlolita/665802 to your computer and use it in GitHub Desktop.
var sDate = new Date()
, today = new Date()
, str = ""
, node;
sDate.setFullYear(2011, 0, 1);
if (sDate > today) {
str = sDate.getFullYear() }
else {
str = '2010-' + sDate.getFullYear() }
// adds the date to the document
node = document.createTextNode(str); // creates a text element that holds the data to write to the document
document.body.appendChild(node); // appends the node to the document (making it visible)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment