Home > Website Design Tips > Website Year Automatic Update With PHP Code

Website Year Automatic Update With PHP Code

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!

Categories: Website Design Tips Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: