Wednesday, July 16, 2008

Snippet 1: Auto Updating your Copyrights ( PHP )

Snippet for Auto Updating your Copyrights

function autoUpdatingCopyright($startYear){
// given start year (e.g. 2004)
$startYear = intval($startYear);
// current year (e.g. 2007)
$year = intval(date('Y'));
// is the current year greater than the
// given start year?
if ($year > $startYear)
return $startYear .'-'. $year;
else
return $startYear;
}

-
Here i am using a function for the year. When year changes then the year next to (C) must also change. This code helps in doing it automatically. It checks the system / server year and shows it on the page.

No comments: