Website Year Automatic Update With PHP Code

May 15, 2008 at 1:42 pm | In Website Design Tips | Leave a Comment
Tags:

Website Year Automatic Update With PHP Code

To update your website year information automaticlly (usually in the site footer) add the following php code to the footer:

<?php
ini_set(‘date.timezone’, ‘Europe/Dublin’);
$startYear = 2006;
$thisYear = date(‘Y’);
if ($startYear == $thisYear) {
echo $startYear;
}
else {
echo “{$startYear}-{$thisYear}”;
}
?>

Save, upload and view. Simple.

Remember to change ‘$startYear = 2007′ to the year your site went live. Also, when adding PHP code your webpage must be a PHP page.

Important note: If you copy and paste the PHP code into an editor (like Dreamweaver) you may need to replace the commas etc. For some reason they don’t ready properly sometimes. Beats me!

No Comments Yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.