JavaScript Date() Day , Month , Year , Second , Minutes , Hours
JavaScript Date() Day , Month , Year , Second , Minutes , Hours เป็นตัวอย่างการ JavaScript กับ Date ในการอ่านค่าวันที่ เช่น Day , Month , Year , Second , Minutes , Hours
date.html
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<form name="frmMain" action="" method="post">
<script language="JavaScript">
date1 = new Date();
document.write("Time = " + date1.getTime() +"<br>");
document.write("Seconds = " + date1.getSeconds() +"<br>");
document.write("Minutes = " + date1.getMinutes() +"<br>");
document.write("Hours = " + date1.getHours() +"<br>");
document.write("Day = " + date1.getDay() +"<br>");
document.write("Date = " + date1.getDate() +"<br>");
document.write("Month = " + (parseInt(date1.getMonth())+1) +"<br>");
document.write("Year = " + date1.getYear() +"<br>");
document.write("FullYear = " + date1.getFullYear() +"<br>");
document.write("<hr>")
date2 = new Date("08 Jun 2012 09:30:21");
document.write("Time = " + date2.getTime() +"<br>");
document.write("Seconds = " + date2.getSeconds() +"<br>");
document.write("Minutes = " + date2.getMinutes() +"<br>");
document.write("Hours = " + date2.getHours() +"<br>");
document.write("Day = " + date2.getDay() +"<br>");
document.write("Date = " + date2.getDate() +"<br>");
document.write("Month = " + (parseInt(date2.getMonth())+1) +"<br>");
document.write("Year = " + date2.getYear() +"<br>");
document.write("FullYear = " + date2.getFullYear() +"<br>");
document.write("<hr>")
/*
getTime() - Number of milliseconds since 1/1/1970 @ 12:00 AM
getSeconds() - Number of seconds (0-59)
getMinutes() - Number of minutes (0-59)
getHours() - Number of hours (0-23)
getDay() - Day of the week(0-6). 0 = Sunday, ... , 6 = Saturday
getDate() - Day of the month (0-31)
getMonth() - Number of month (0-11)
getYear() - The four digit year (1970-9999) - Deprecated
getFullYear() - The four digit year (1970-9999)
*/
</script>
</form>
</body>
</html>