Show current year on web site

In this article we will show you how to display the current year in the footer section of your website.

If you have a website, you certainly have an area dedicated to copyright, somewhere at the bottom of the page. It may happen that the year, that is shown there, does not take into account the current date. In this case, every new year, you will have to adjust this year manually.

copyright-year

In fact, there is a much better approach, which enables you to manage the current year automatically, adjusting itself to the system's date.

Depending on the technology used, there are three most common ways to do so:

1 - Javascript

<script>document.write(new Date().getFullYear())</script>

2 - PHP

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

3 - ASP.NET

<%= DateTime.Now.Year.ToString() %>

Print Friendly, PDF & Email

Leave a Reply