Automatic Copyright Year | CSS-Tricks


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.