Javascript Dateの基本的な特徴
2331 ワード
<SCRIPT LANGUAGE="JavaScript">
// Date
var date = new Date();
// javascript Date java java.util.Date , java Date。
// UTC Coordinated Universal Time 1970 1 1 +/-285616
// ,javascript 2 Date.parse(); Date.UTC();
// Date.parse , ( )。
var date1 = new Date(Date.parse("May 19,2012"));
date1 = new Date("May 19,2012");// , Date.parse
document.write(date1+"</br>");
var abm = new Date(" 19,2012");// NaN
document.write(abm+"</br>");
// 。。。。。。( 32 , )
date1 = new Date(Date.UTC(2012,0));// GMT
document.write(date1+"</br>");
//
var date2 = new Date(2012,1,6,23,59,12);//
document.write((date1>date2)+"</br>");
// toString toLocaleString , ,
document.write(date1.toDateString()+"</br>");// Sat Jan 1 2000
document.write(date1.toTimeString()+"</br>");//08:00:00 UTC+0800
document.write(date1.toLocaleDateString()+"</br>");//2000 1 1
document.write(date1.toLocaleTimeString()+"</br>");//8:00:00
document.write(date1.toLocaleString()+"</br>");// 2000 1 1 8:00:00
document.write(date1.toGMTString()+"</br>");// Sat, 1 Jan 2000 00:00:00 UTC
document.write(date1.toUTCString()+"</br>");// Sat, 1 Jan 2000 00:00:00 UTC
// ,
// getTime getDate UTC , getDate getUTCDate() setUTCDate
// getFullYear getMonth getDay getHours getMinutes getSeconds getMillseconds
document.write(date1.getFullYear + "</br>");//
document.write(" :"+date2.getFullYear()+" "+ date2.getMonth()
+" "+date2.getDate()+" "+ date2.getHours()+":"+date2.getMinutes()+":"+date2.getSeconds());
</SCRIPT>