<script>
function nowtime()
{
var date =new Date();
//当前年份
var year=date.getFullYear();
//当前月份
var month=date.getMonth()+1;
//当前天数
var day=date.getDate();
//当前小时
var hour=date.getHours();
//当前分钟
var minutes=date.getMinutes();
//当前秒
var seconds=date.getSeconds();
//当前星期
var weeks=date.getDay();
var days=["天","一","二","三","四","五","六"];
var showtime=document.getElementById("showtime");
showtime.innerHTML=year+"年"+month+"月"+day+"日"+hour+"时"+minutes+"分"+seconds+"秒"+"星期"+days[weeks];
}
//每秒执行一次
window.setInterval('nowtime()',1000);
</script>
js获取当前时间
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
day.js 时间戳
day.js 的时间戳 希望大家可以补充
时间段 时间戳 时间处理 -
十分钟时间搞懂怎么用JS代码渲染实时时间
十分钟时间搞懂怎么用JS代码渲染实时时间
数据 数组 时间对象 -
Js求当前时间
JavaScript 求当前时间
JavaScript Js 当前时间 -
js同步获取当前时间
js获取时间戳,并同步显示当前时间<p><span id="year">2020</span>年<span id="mo...
javascript js python java jquery -
js显示当前系统的时间
http://www.jb51.net/article/75711.htm
javascript 系统时间 标题栏 -
JS获取当前时间的方法
JS获取当前时间的方法
时间戳 js获取时间 格式化时间 js时间操作 封装方法