Using PHP to Update Your Copyright

Being that we are on the verge of entering a new year, I felt that this was an ‘on topic’ little tutorial to share! Any developer who utilizes PHP should know that it can help save time, which in turn increases productivity. PHP offers a wide variety of tools to help you to create smart, dynamic website. Here is a little trick to help you to not have to go to every single website you design and develop to manually update the copyright information to the current year. Depending on how you have a site setup, that could be a pretty decent task, especially if you’re not utilizing any sort of global variables.

Please note that your site must be on PHP friendly hosting as well as the following code must be in a PHP file or template rather than an HTML file as it will not work!

Copyright &copy; <?php ini_set('date.timezone', 'America/New_York'); echo date('Y'); ?>

Since today is December 31, 2009, the following would render: Copyright © 2009

However, if you were to visit the same page tomorrow it would render: Copyright © 2010

Being that we (meaning us physically) are located in the New York timezone, we popped in the correct code for PHP to recognize the appropriate year for our timezone. All you would need to do is replace that spot with the appropriate timezone and you’re all set! A link is provided below to find your timezone.

Now this is a very simple approach to using PHP to update the year for you. With further research you can look into taking this to the next step.

Happy New Year, and have fun!

Stay In The Loop

Social Gathering

Join our newsletter to get notified about the happenings here at J Taylor Design.