PDA

View Full Version : Help



cynfinnegan1163
December 3rd, 2007, 09:21
I'm looking for a bit of Javascript that will automatically update the copyright date on my site. I turned 44 this past Friday and I'm getting too lazy in my old age to update the copyright every year.

iBrightDev
December 3rd, 2007, 10:12
as far as i know, there isnt just a year function for JS, i could be wrong though. i know you can do the exact day or time though. but, if you name your pages .php, instead of .html, if you dont already have them as php, then you can use a php date function.


<?=date("Y")?>

krakjoe
December 3rd, 2007, 12:23
<script language="javascript">
var odate = new Date( );
document.write( odate.getFullYear() );
</script>


or



<script language="javascript">
document.write( new Date( ).getFullYear() );
</script>

iBrightDev
December 3rd, 2007, 13:36
see, i knew Joe would tell me that there is a way in JS. lol. sorry i couldnt be more helpful.

Darknight
December 3rd, 2007, 13:48
LOL @ the size differnce between PHP and JS to get the same result :p
Im wondering what it would be for the day/month/year though
Cause that could come in handy for me on a cpl of html pages.

krakjoe
December 3rd, 2007, 14:06
<script language="javascript">
var oDate = new Date( );
document.write( oDate.getDate( ) + '/' + (oDate.getMonth( ) + 1) + '/' + oDate.getFullYear( ) );
</script>

iBrightDev
December 3rd, 2007, 14:17
LOL @ the size differnce between PHP and JS to get the same result :p
Im wondering what it would be for the day/month/year though
Cause that could come in handy for me on a cpl of html pages.

if you are going for php.


<?=date("l, F d, Y")?>

that will display something like...

Monday, December 02, 2007

JohnN
December 3rd, 2007, 17:29
just a pointer (yes this is nazi level) using short tags isn't really great practice, just stick to regular ones, its really not that much extra.

iBrightDev
December 4th, 2007, 00:11
just a pointer (yes this is nazi level) using short tags isn't really great practice, just stick to regular ones, its really not that much extra.

what exactly would you be talking about, and please give an example of what you mean?

Darknight
December 4th, 2007, 06:53
Thanks people :beer: