Copy Code code as follows:
<title></title>
<script>
/*
Declaration time
var date = new Date ();
alert (date);/Current Time
Alert (date.tolocalestring ());//Convert to local time
Alert (Date.getfullyear ());//Show Year
Alert (Date.getmonth () + 1);//Display month 0-11, you need to add 1
Alert (Date.getdate ());//display date in January
Alert (Date.getday ());//show the date of the week, Day of the week
Alert (date.gethours ());//Get hour time
Alert (Date.getminutes ());//Get current minute
Alert (Date.getseconds ());//get current number of seconds
Alert (Date.getmilliseconds ());//Get the current number of milliseconds
Alert (Date.gettime ())//Gets the millisecond value from 0 o'clock midnight, January 1, 1970, to the current time
*/
Get year, month, day, hour, minute, second, respectively
var mydate = new Date ();
var year = Mydate.getfullyear ();
var month = Mydate.getmonth () + 1;
var date = Mydate.getdate ();
var hours = mydate.gethours ();
var minutes = mydate.getminutes ();
var seconds = mydate.getseconds ();
Month is displayed as two digits as in September
if (Month < 10) {
month = "0" + month;
}
if (Date < 10) {
Date = "0" + date;
}
Time Stitching
var dateTime = year + "years" + month + "Month" + Date + "Day" + Hours + "time" + minutes + "min" + seconds + "seconds";
document.write (dateTime);//Print Current time
</script>
<body>
<!--event response-->
<input type = "button" value= "click" onclick= "Show ()"/>
</body>