Javascript| page Many netizens should find that many Web pages have the function of displaying time and date, this is not difficult, using Visual Web-making software dreameaver can insert time and date directly. But today we use JavaScript to do this, and to understand the role of JavaScript in the Web programming language, the principle of which is to display the date and time of a personal client machine on a Web page through the execution of a JavaScript program.
The source program is as follows:
In this case, we must first establish a date variable, which can be done by today=newdate (). If no specific time and date are specified, the browser will take the time of the local client machine. If you put it in the variable today, notice here that we don't declare the form of today's variable.
In addition to the above features, you can set date objects in advance by setting the date as follows:
docstarted= new Date (96,0,13)
First is the year, then the month (but remember minus 1), then the day. The same method can also be combined with time settings. The first three docstarted =newdate (96,0,13,10,50,0) are the year, month, and day of the date, followed by time, minutes, and seconds.
Finally, we have to remind you that JavaScript does not have an actual date form, but it can display the date and time effortlessly, since it calculates the current time from 1/1/1970 0 0h with MS (milliseconds), which may sound complicated. But you don't have to worry, it has a standard common function to calculate, you just know how to use it.