<script> <br><br>/* <br><br>//Declaration time<br>var date = new Date(); <br> alert(date);//Current time<br>alert(date.toLocaleString());//Convert to local time<br>alert(date.getFullYear());//Display year<br>alert(date. getMonth() 1);//Display the month 0-11, you need to add 1 <br>alert(date.getDate());//Display the date in January <br>alert(date.getDay());/ /Display the date of the week, day of the week<br>alert(date.getHours());//Get the hour time<br>alert(date.getMinutes());//Get the current minutes<br>alert(date.getSeconds ());//Get the current number of seconds<br>alert(date.getMilliseconds());//Get the current number of milliseconds<br>alert(date.getTime());//Get the date since January 1, 1970 At midnight on the day, the millisecond value to the current time <br>*/ <br>//Get the year, month, day, hour, minute, and second respectively <br>var myDate = new Date(); <br>var year = myDate.getFullYear(); <br>var month = myDate.getMonth() 1; <br>var date = myDate.getDate(); <br>var hours = myDate.getHours(); <br>var minutes = myDate.getMinutes(); <br>var seconds = myDate.getSeconds(); <br><br>//The month is displayed as two digits such as September <br>if(month < 10 ){ <BR> month = "0" month; <BR>} <BR>if(date < 10 ){ <BR>date = "0" date; <BR>} <br><br>//Time splicing<BR>var dateTime = year "year" month "month" date "day" hours "hour" minutes "minute" seconds "second"; <br><br>document.write(dateTime);//Print the current time <br><br><br><br></script>
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn