First, Introduction
1. Date object: The Date object, which can be used to obtain information such as dates, times, weeks, time zones, etc.
2. Array object: That is, the array object, that is, the PHP arrays in JS in the form of JS to create.
Second, the example code
/** * Date: Includes date, time, week, time zone, etc. */function myFunction () {//Date document.write (date () + "<br/>");//Standard timestamp document.write (new Date (). GetTime () + "<br/>");//1970.01.01-present time the number of milliseconds var d = new Date ();d. setFullYear (1980, N);d Ocument.write (D + ") <br/>);//Displays the 1981-12-18 standard timestamp document.write (new Date (). toUTCString () + "<br/>");// Converts a date to a string document.write (new Date (). GetDay () + "<br/>");//Get the day, minute, second}/** * week = + convert * Array Object */function MyFunction2 () {/*var weekday = new Array (7); weekday[0] = "Sunday"; weekday[1] = "Monday"; weekday[2] = "Tuesday"; weekday[3] = "Wednesday"; EKDAY[4] = "Thursday"; weekday[5] = "Friday"; weekday[6] = "Saturday"; */var weekday=new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", " Saturday ");//The above 2 kinds of JS definition array objects can be var x = new Date (). GetDay ();//Friday =>5document.write (" Today is "+ weekday[x]);//convert number to Custom week}/ * * time = alarm */function myFunction3 () {var d = new Date (), var h = d.gethours (); var m = D.getminutes (); var s = D.getsecon DS (); h = checktime (h); m = Checktime (m); s = checktime (s);d Ocument.geteleMentbyid ("Div1"). innerhtml=h+ ":" + M + ":" +s;settimeout ("MyFunction3 ()", 1000);//1 seconds to refresh once, here the method name must be in single or double quotation marks function Checktime (x) {if (x<10) {x = "0" + x;} return x;}}
JS (iii) Date object and Array object