At last night’s Winnipeg WordPress Meetup, I gave a PHP For Absolute Beginners talk. It was a fun chance to put myself in the mindset of a beginner again–which wasn’t that long ago!
At the end I gave a quick example of doing a dynamic copyright footer. Here’s the code:
$start_date = '2005';
$end_date = date( 'Y' );
// only print the start date and dash if it's different than the end date
if ( $start_date != $end_date ) {
echo $start_date . '–';
}
// always print the end date
echo $end_date
And, here’s the slides:
Dynamic year in the footer is one of the first things I learned in PHP as well. Still surprised when I find a footer in a PHP framework that doesn’t have it….