Posted By

scorpayllc on 05/02/13


Tagged


Versions (?)

Automatic Copyright Year | CSS-Tricks


 / Published in: PHP
 

  1. &copy; <?php echo date("Y") ?>
  2.  
  3. &copy; 2008-<?php echo date("Y") ?>
  4.  
  5. <?php function auto_copyright($year = 'auto'){ ?>
  6. <?php if(intval($year) == 'auto'){ $year = date('Y'); } ?>
  7. <?php if(intval($year) == date('Y')){ echo intval($year); } ?>
  8. <?php if(intval($year) < date('Y')){ echo intval($year) . ' - ' . date('Y'); } ?>
  9. <?php if(intval($year) > date('Y')){ echo date('Y'); } ?>
  10. <?php } ?>
  11.  
  12. <?php auto_copyright(); // 2011?>
  13.  
  14. <?php auto_copyright('2010'); // 2010 - 2011 ?>

Report this snippet  

You need to login to post a comment.