RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Add Automatic Copyright Year With PHP

Virtually every website has a copyright icon and string indicating the years of website operation. It's surprising how many sites still use a single static date that doesn't reflect the years the site has existed. The following function is designed to return the date of website origin through to the current year.

1
<?php 
2
/*
3
 Add Automatic Copyright Year With PHP
4
 http://www.beliefmedia.com/code/php-snippets/copyright-year
5
*/
6
 
7
function bm_copyright($year = '') {
8
  if ($year == '') return '© ' . date('Y');
9
 return ( $year == date('Y') ) ? '© ' . $year : '© ' . $year . ' - ' . date('Y');
10
}
11
 
12
/* Usage */
13
echo bm_copyright('2012');

Returns: © 2012 - 2017.

Of course, you can return the current year with just the following:

1
<?php 
2
echo '© ' . date('Y');

The from and to date can be returned with the following (the only difference to the function above is that it doesn't correct if the start and current year are the same).

1
<?php 
2
echo '© 2012 - ' . date('Y');

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment