Get the Year with Code and Output It in the Footer Copyright

Another year has passed. Are some friends busy changing the year in their site’s footer copyright? Some forget and stay stuck years in the past?

Grassroots webmasters who aren’t pros wonder: why does Baidu’s or Sina’s footer year change right after midnight? Are their admins that efficient? Actually it’s not done by hand — the program does it automatically. It reads the server’s time, takes the year, and outputs it, so no one has to find the file and edit code. Take a look at my blog’s footer code:

[php] //Main code: echo date(“Y”); Copyright &copy; 2012 - <?php echo date(“Y”); ?> NeilRen.Com Rencom All Rights Reserved wp_footer();//Outputs WordPress’s footer function [/php]

Using echo date("Y") outputs the year, so I don’t have to change it manually every year. Of course this assumes the server time is accurate; but a server is surely online, and being online it auto-syncs network time, so normally we don’t worry about it.

Below is the ASP code to get and output the current year:

[code] //ASP: get and output the current year <%=Year(now())%> [/code]