完整(四位数)年份或最后两位数的年份更新,使用JavaScript
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了完整(四位数)年份或最后两位数的年份更新,使用JavaScript相关的知识,希望对你有一定的参考价值。
For full year (four digits): JS: today=new Date(); y0=today.getFullYear(); html: <p>© <script type="text/javascript">document.write(y0);</script> Somecompany, Inc. All Rights reserved.</p> - - - - - For partial year (last two digits): JS: var foo = (new Date().getFullYear()).toString(); // Contains last two characters of the full year. // ex: 2003 evaluates to 03. var bar = foo.substring(foo.length, 2); HTML: <p>All contents ™ and © 2005-<script type="text/javascript">document.write(bar);</script> Somecompany, Inc. unless otherwise noted herein. All rights reserved.</p>
以上是关于完整(四位数)年份或最后两位数的年份更新,使用JavaScript的主要内容,如果未能解决你的问题,请参考以下文章