javascript文法のDate対象と小判例


<!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>
<script type="text/javascript"> 
/*
    (Date)
 
 
*/
	var date = new Date(); //          
	document.write(" :"+ date.getFullYear()+"<br/>");
	document.write(" :"+ (date.getMonth()+1)+"<br/>");
	document.write(" :"+ date.getDate()+"<br/>");
	
	document.write(" :"+ date.getHours()+"<br/>");
	document.write(" :"+ date.getMinutes()+"<br/>");
	document.write(" :"+ date.getSeconds()+"<br/>");
	
	//xxxx yy dd   hh:mm:ss
	
	//document.write("     :"+date.toLocaleString());
	document.write("     :"+date.getFullYear()+" "+(date.getMonth()+1)+" "+date.getDate()+"  "+
	date.getHours()+":"+date.getMinutes()+":"+date.getSeconds());
 
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>     </title>
</head>
<body>
	
 
</body>
</html>
実例:スケジュール.
<!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=utf-8" />
<title>     </title>
</head>
<body>
	      :<span id="time"></span>
</body>
 
 
<script type="text/javascript"> // script       ,    <span style="font-family: Arial, Helvetica, sans-serif;">document.getElementById("time");    。             time id    。</span>
	
	function getCurrentTime(){
		//          
		var date = new Date();
		//                。
		var timeInfo =  date.getFullYear()+" "+(date.getMonth()+1)+" "+date.getDate()+"  "+
	date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
	
		// span  
		var  spanObj = document.getElementById("time");
		//  span      
		spanObj.innerHTML = timeInfo.fontcolor("red");
	}
 
	getCurrentTime();
	
	//    .
	window.setInterval("getCurrentTime()",1000); /* setInterval       ,             ,                                                                    。*/
			
 
</script>
 
 
</html>