Automatically Update the Copyright Year on Your Website

Here's the JavaScript. Copy and paste it wherever you want the current year to appear:

<script language="javascript" type="text/javascript">
	var today = new Date()
	var year = today.getFullYear()
	document.write(year)
</script>

And here's the PHP code to output current year:

<?php echo date("Y"); ?>

HTML start year with PHP current year:

&copy; 2008-<?php echo date("Y") ?>

PHP script for start date with error protection:

<?php 
function auto_copyright($year = 'auto'){ 

	if(intval($year) == 'auto'){ 
	$year = date('Y'); 
	} 

	if(intval($year) == date('Y')){ 
	echo intval($year); 
	} 
 
	if(intval($year) < date('Y')){ 
	echo intval($year) . ' - ' . date('Y'); 
	} 

	if(intval($year) > date('Y')){ 
	echo date('Y'); 
	} 

} ?> 

here's how to use it in your HTML code

<!--?php auto_copyright(); // 2011?-->
      or
<!--?php auto_copyright('2010');  // 2010 - 2011 ?-->