Skip to content

Instantly share code, notes, and snippets.

@Drabush
Created February 6, 2016 12:34
Show Gist options
  • Save Drabush/13f48c8aee66b3c27e46 to your computer and use it in GitHub Desktop.
Save Drabush/13f48c8aee66b3c27e46 to your computer and use it in GitHub Desktop.
Auto update copyright year
<?php
/*
* copyrightYear: get years to copyright footer
* Parameters:
* start [optional]: First year of website.
* DEFAULT: nothing.
* separator [optional]: the space string between start and current year
* [[copyrightYear]] // return: 2016
* [[copyrightYear? &start=`2014`]] // return: 2014 – 2016
*/
$start = $modx->getOption('start', $scriptProperties, date("Y"));
$separator = $modx->getOption('separator', $scriptProperties, ' - ');
$now = date("Y");
$start = isset($start)? $start : $now;
$years = ($now > $start && $start > '1970') ? $start . $separator . $now : $now;
return $years;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment