PDA

View Full Version : Miscellaneous Hacks - JavaScript: Copyright Year Generation


King Kovifor
01 Feb 2009, 15:52
Just because a bunch of people wanted me to release this. Here's a little JavaScript I wrote that you can place in your copyright statement to keep your year up to date. Just put it where you want the year to display:

<script type="text/javascript">
d = new Date();
y = d.getFullYear();
document.write(y);
</script>

OR

<script type="text/javascript">d = new Date();y = d.getFullYear();document.write(y);</script>

They both do the same thing, one's just on a single line. :)

A JS file attached just in case you want to keep it as a back up.

Thanks to Gasper for reminding me to put in the text/javascript tag. :)

Also, this works with any version of vBulletin (or should) and can be seen on vB.org.

UncoderMom
01 Feb 2009, 16:00
*clicks install*

teehee

Lynne
01 Feb 2009, 16:49
Thanks!

digicom
01 Feb 2009, 17:07
Thankyou:up:

Paul M
01 Feb 2009, 17:26
Well, since we are using it here, id better click install. :)

ForumsMods
01 Feb 2009, 17:29
Installed. ;)
Simple hack, but very useful.

Vaupell
01 Feb 2009, 17:47
ahh here it was, ;) installed ofc.

King Kovifor
01 Feb 2009, 17:51
Well, since we are using it here, id better click install. :)

I was actually quite surprised that you used it. :) I'm sure you could have whipped that up quite faster than me (it sadly took me like 5 minutes as my first code failed (document.write(Date.getFullYear()) ;)).

Magnumutz
01 Feb 2009, 19:34
Thanks dude, installed :D

Ryan Ashbrook
01 Feb 2009, 20:41
Thanks. :D

-=Sniper=-
01 Feb 2009, 21:05
I was actually quite surprised that you used it. :) I'm sure you could have whipped that up quite faster than me (it sadly took me like 5 minutes as my first code failed (document.write(Date.getFullYear()) ;)).

nearly there, this would have worked.

document.write((new Date()).getFullYear());

King Kovifor
01 Feb 2009, 21:10
nearly there, this would have worked.

document.write((new Date()).getFullYear());

Gah. I'm new to JavaScript. And I have to say, it's very low skill. But that totally makes sense. :D

m002.p
02 Feb 2009, 22:12
Good job here mate. Javascript reminds me of unreal code in games - a mess to understand at the best of times, but very useful too. Compliments PHP nicely.

King Kovifor
03 Feb 2009, 19:43
Good job here mate. Javascript reminds me of unreal code in games - a mess to understand at the best of times, but very useful too. Compliments PHP nicely.

I am still learning. I got a book but half the time, it's just bad. ;)