mddanishyusuf / dailyhack

🐱‍💻 Tiny Tiny Hacks we use in our daily life.
https://dailyhack.now.sh/
149 stars 15 forks source link

Automatically Update Your Website Footer #43

Open fajarsiddiqfs opened 5 years ago

fajarsiddiqfs commented 5 years ago

👨‍💻Automatically updating copyright year or other dynamic timestamp. ✅Just copy a code snippet


💻JavaScript Snippets - For Static Sites

<script type="text/javascript">
  document.write(new Date().getFullYear());
</script>

😻It will show

2019

If you want a bit more information, here's a snippet you can customize:

&copy; 2010<script>new Date().getFullYear()>2010&&document.write("-"+new Date().getFullYear());</script>, Company.

It will give you:

© 2010-2019, Company.

💻PHP Snippets - For Dynamic Sites

<?php echo date("Y"); ?>

😻It will show

2019

If you want a bit more information, here's a snippet you can customize:

&copy; <?php
  $fromYear = 2008; 
  $thisYear = (int)date('Y'); 
  echo $fromYear . (($fromYear != $thisYear) ? '-' . $thisYear : '');?> Company.

It will give you: © 2010-2019, Company.

mddanishyusuf commented 5 years ago

It's Awesome @fajarsiddiqfs

fajarsiddiqfs commented 5 years ago

thanks dude! yes i learn this quickly for my site!