<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>date对象设置set</title> </head> <body> <was>script Today = new new a Date (); var weeks = [ " date " , " one " , " two " , " three " , " four " , " five " , " six " ]; // today.setFullYear (2222); / Year / set 2222 // document.write (today.getFullYear () + "<br />"); // 2222 // today.setMonth (13); // set the month to 13 // document.write (Today .getMonth () + "<br />" );// 1, after more than 12 in January next year will automatically enter //document.write (today.getFullYear () + "<br />"); // 2223, due to the month setting above 13, while additional year // get today for next year is the week // today.setFullYear (Today .getFullYear () + 1); // the year today acquired +1 // document.write (weeks [today.getDay ()]); // time after the output of the +1 year // get additional time var year = today.getFullYear (); var month The = today.getMonth () + . 1 ; var DATE = today.getDate (); // hours, minutes, seconds ............ omitted var Tim = new new a Date (year - . 1 , month The, DATE + 50 ); //Last year: This year -1; 50 days: Today +50; document.write ( " last 50 days of today is: " + tim.getFullYear () + " of " + tim.getMonth () + " month " + tim.getDate () + " day week " + weeks [tim.getDay ()]); </ Script > </ body > </ HTML >