Skip to Content

How to Dynamically Change the Copyright Date on Your Website

I was recently asked to change the copyright date on a handful of websites. The websites all were using a CMS system, but when the person who built them set them up, they inserted a static year. So, every year someone has to go in and change them. Thankfully, there are only about 10 or so page templates that are used so it is a pretty quick change. However, it would have been much easier if -- the person who built the site... added a line or two of code ;) to pull the year off the server time. This way, every year the date will automatically change... making life easier for someone!

Here are a couple methods that will produce the result we are looking for:

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

Using ASP
<% Response.Write Year(now) %>

Using JAVASCRIPT
Technically JS is client side, so this option doesn't really pull the date off the server... It pulls it from the clients computer. So, if their date isn't correct this wont be either. But it should work most of the time.
<script type="text/javascript">
var d = new Date();
document.write(d.getFullYear());
</script>

blog comments powered by Disqus
Get Adobe Flash playerPlugin by wpburn.com wordpress themes