- by Judd Lyon
- Aug 30, 2008
- Filed in: Web design & development
Website copyright notices are ubiquitous; you can find them in the footer of almost any site. It's also easy to spot copyright notices that haven't been updated in years, which could potentially send the signal that nobody is behind the wheel. A simple solution is to have the year update dynamically.
Here's several ways to "set it and forget it":
JavaScript
© <script type="text/javascript">
//<![CDATA[
var d = new Date(); document.write(d.getFullYear());
//]]>
</script>
PHP
© <?php echo date("Y"); ?>
Ruby/ERB
© <%= Time.now.year %>
Django/Python
© {% now "Y" %}
ASP
© <% Response.Write Year(now) %>
JSP
© <jsp:useBean id="now" class="java.util.Date"/>
<fmt:formatDate value="${now}" type="DATE" pattern="yyyy"/>
ActionScript/Flash
trace("© " + new Date().getFullYear();
Comments
There are no comments for this entry.
