Common methods of JS Date Object
Creating an Event Object
var now = new Date (); The current time is returned by default in the case of no reference
Get year
var y=now.getfullyear ();
Get month
var m=now.getmonth () +1;//returns 0-11
Get Day
var d= now.getdate ();
Get hours
var h =now.gethours ();
Get minutes
var i =now.getminutes ();
Get seconds
var s =now.getseconds ();
Get the day of the week
Var week =now.getday ();//0-6 0 for Sunday
var weeks=[' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six ';
Console.log (y+ "year" +m+ ' month ' +d+ ' Day ' +h+ ' when ' +i+ ' min ' +s+ ' s ' + ' Week ' +weeks[week]);//July 17, 2017 17:55 41 second Monday
var times =now.gettime ();//Get timestamp
All of the above methods get replaced with set example setFullYear () setmonth () is the set time object
If you set the month parameter Setmonth (13) More than the month, the year plus 1 and so on
Example: Calculate the day of the week after 50 days
Method 1:
Now.setdate (Now.getdate () +50);
Console.log (Weeks[now.getday ());
Method Two
var now = new Date ();
var mytime=new date (Now.getfullyear (), Now.getmonth (), now.getdate () +50);//Set the date and time of the month and then the day must be
Console.log (Weeks[mytime.getday ()))
Common methods of JS Date Object