Rolling with the Times - How to Make Your Web Pages Automatically Update to the Current Year
Have you ever seen the copyright symbol at the bottom of a web page that references a year that passed 5 years ago? Five years is an eternity on the web, and people will get the impression your site is dead.
Here's a trick to get your site to display the correct year within your copyright notice. If your web pages are run by a server that uses PHP (e.g.; your web page is www.mysite.com/mypage.php), then remove the year (e.g.; "2011") and replace with this code:
<?php echo date('Y'); ?>
If your server isn't running PHP on your pages, you can fake it using JavaScript in your web page. Again, just replace the year with the following code:
<script type="text/javascript">
var currentTime = new Date();
var year = currentTime.getFullYear();
document.write(year);
</script>
Best regards,
Dan
