js / php 网站底部版权文字自动改变年份

js

<script>document.write(new Date().getFullYear());</script>

php

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

例如:

<p class="copyright">Copyright © <script>document.write(new Date().getFullYear());</script> <a href="https://">xxx</a> All Rights Reserved.</p>

 当然你还可以

            <script type="text/javascript">
copyright=new Date();//取得当前的日期
update=copyright.getFullYear();//取得当前的年份
document.write("Copyright © 2016-"+ update + ' <a href="/"><b>xxx</b></a> All rights reserved. ');

</script>

这样做好网站后就不用每年再去修改 foot 了

本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/15754161.html

原文地址:https://www.cnblogs.com/HGNET/p/15754161.html