如何在html中获取系统时间
3个回答
展开全部
<script language="javascript" type="text/javascript">
function getFullStringTime(){
var currentDate = new Date();
var strMinute = currentDate.getMinutes()<10?("0"+currentDate.getMinutes()):currentDate.getMinutes();
var strSecond = currentDate.getSeconds()<10?("0"+currentDate.getSeconds()):currentDate.getSeconds();
with(document){
write("现在时间是:","<br>");
if(currentDate.getDay()==0){
write(currentDate.getYear()+1900,"年",currentDate.getMonth()+1,"月",currentDate.getDate(),"日"," ","星期日"," ",currentDate.getHours(),":",strMinute,":",strSecond);
}else{
write(currentDate.getYear()+1900,"年",currentDate.getMonth()+1,"月",currentDate.getDate(),"日"," ","星期日"," ",currentDate.getHours(),":",strMinute,":",strSecond);
}
}
}
getFullStringTime();
</script>
function getFullStringTime(){
var currentDate = new Date();
var strMinute = currentDate.getMinutes()<10?("0"+currentDate.getMinutes()):currentDate.getMinutes();
var strSecond = currentDate.getSeconds()<10?("0"+currentDate.getSeconds()):currentDate.getSeconds();
with(document){
write("现在时间是:","<br>");
if(currentDate.getDay()==0){
write(currentDate.getYear()+1900,"年",currentDate.getMonth()+1,"月",currentDate.getDate(),"日"," ","星期日"," ",currentDate.getHours(),":",strMinute,":",strSecond);
}else{
write(currentDate.getYear()+1900,"年",currentDate.getMonth()+1,"月",currentDate.getDate(),"日"," ","星期日"," ",currentDate.getHours(),":",strMinute,":",strSecond);
}
}
}
getFullStringTime();
</script>
2017-08-07
展开全部
var myDate = new Date();
myDate.getYear(); //获取当前年份(2位)
myDate.getFullYear(); //获取完整的年份(4位,1970-????)
myDate.getMonth(); //获取当前月份(0-11,0代表1月)
myDate.getDate(); //获取当前日(1-31)
myDate.getDay(); //获取当前星期X(0-6,0代表星期天)
myDate.getTime(); //获取当前时间(从1970.1.1开始的毫秒数)
myDate.getYear(); //获取当前年份(2位)
myDate.getFullYear(); //获取完整的年份(4位,1970-????)
myDate.getMonth(); //获取当前月份(0-11,0代表1月)
myDate.getDate(); //获取当前日(1-31)
myDate.getDay(); //获取当前星期X(0-6,0代表星期天)
myDate.getTime(); //获取当前时间(从1970.1.1开始的毫秒数)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以用javascript,在html的head里面写如下代码
<script language="javascript">
var now=new Date();
document.write("今天是"+now.year()+"年"+now.month()+"月"+now.day()+“日”);
</script>
<script language="javascript">
var now=new Date();
document.write("今天是"+now.year()+"年"+now.month()+"月"+now.day()+“日”);
</script>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询