<script language="javascript">var myDate=new Date(); document.write(myDate.getYear().toString() "<br>");//获取当前年份(2位) document.write(myDate.getFullYear().toString() "<br>");//获取当前完整的年份(4位,1970-????) document.write(myDate.getMonth().toString() "<br>");//获取当前月份(0-11,0代表1月) document.write(myDate.getDate().toString() "<br>");//获取当前日(1-31) document.write(myDate.getDay().toString() "<br>");//获取当前星期X(0-6,0代表星期天) document.write(myDate.getTime().toString() "<br>");//获取当前时间(从1970-1-1开始的毫秒数) document.write(myDate.getHours().toString() "<br>");//获取当前小时数(0-23) document.write(myDate.getMinutes().toString() "<br>");//获取当前分钟数(0-59) document.write(myDate.getSeconds().toString() "<br>");//获取当前秒数(0-59) document.write(myDate.getMilliseconds().toString() "<br>");//获取当前毫秒数(0-999) document.write(myDate.toLocaleDateString().toString() "<br>");//获取当前日期return myDate.getYear()</script>,下面我们就来说一说关于js实现显示当前时间?我们一起去了解并探讨一下这个问题吧!
js实现显示当前时间
<script language="javascript">var myDate=new Date(); document.write(myDate.getYear().toString() "<br>");//获取当前年份(2位) document.write(myDate.getFullYear().toString() "<br>");//获取当前完整的年份(4位,1970-????) document.write(myDate.getMonth().toString() "<br>");//获取当前月份(0-11,0代表1月) document.write(myDate.getDate().toString() "<br>");//获取当前日(1-31) document.write(myDate.getDay().toString() "<br>");//获取当前星期X(0-6,0代表星期天) document.write(myDate.getTime().toString() "<br>");//获取当前时间(从1970-1-1开始的毫秒数) document.write(myDate.getHours().toString() "<br>");//获取当前小时数(0-23) document.write(myDate.getMinutes().toString() "<br>");//获取当前分钟数(0-59) document.write(myDate.getSeconds().toString() "<br>");//获取当前秒数(0-59) document.write(myDate.getMilliseconds().toString() "<br>");//获取当前毫秒数(0-999) document.write(myDate.toLocaleDateString().toString() "<br>");//获取当前日期return myDate.getYear()</script>
,