Last active
August 16, 2018 04:26
-
-
Save w5d/1610e101819cbfac2243 to your computer and use it in GitHub Desktop.
Copyright
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##From https://css-tricks.com/snippets/php/automatic-copyright-year/## | |
/*Current year only*/ | |
© <?php echo date("Y") ?> | |
//With start year | |
© 2008-<?php echo date("Y") ?> | |
Start date with error protection | |
<?php function auto_copyright($year = 'auto'){ ?> | |
<?php if(intval($year) == 'auto'){ $year = date('Y'); } ?> | |
<?php if(intval($year) == date('Y')){ echo intval($year); } ?> | |
<?php if(intval($year) < date('Y')){ echo intval($year) . ' - ' . date('Y'); } ?> | |
<?php if(intval($year) > date('Y')){ echo date('Y'); } ?> | |
<?php } ?> | |
Usage: | |
<?php auto_copyright(); // 2011?> | |
<?php auto_copyright('2010'); // 2010 - 2011 ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment