Tools
- Sandbox
- Paste Code
- Snippets
- Generators
- Checks
- Convertors
Automatic Copyright Year in PHP
Snippet
Share
Do you find this snippet useful? Then share it with your friends or colleagues. This will help us to make our free web tools better.
To add a copyright year in PHP that updates with the current year, you can use the code below:
© <?php echo date("Y"); ?>
With start year:
© 2016-<?php echo date("Y"); ?>
Smart function:
<?php
function autoCopyright($year = false){
if($year == false) $year = date('Y');
if(intval($year) == date('Y')) return intval($year);
if(intval($year) < date('Y')) return intval($year) . ' - ' . date('Y');
if(intval($year) > date('Y')) return date('Y');
}
?>
© <?=autoCopyright(); // current year ?>
© <?=autoCopyright(2017); // 2017-{current year} ?>