有一些东西,需要记下来,为以后使用,这是一个js获得当前实时日期和时分秒星期的脚本:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
window.onload=function getNowTime(){
//取得当前时间
var now= new Date();
var year=now.getFullYear();
var month=now.getMonth()+1;
var day=now.getDate();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
var week=now.getDay();
var weekname="星期"+"天一二三四五六".split('')[week];
var nowdate=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second+" "+weekname;
document.getElementById("break_date").value = nowdate;
window.setTimeout("getNowTime()",1000);
}
</script>
</head>
<body>
<input type="text" id="break_date" size="30"/>
</body>
</html>
本文介绍了一段JavaScript脚本,该脚本能够实现实时显示当前的日期、时间(包括小时、分钟、秒)以及星期。通过简单的HTML页面展示,并利用JavaScript内置的Date对象来获取这些信息。
4643

被折叠的 条评论
为什么被折叠?



