Nonsense said, mainly through the following seven aspects of the summary of the time to deal with the relevant knowledge.
1. Get Current time
function Getnowtime () {return
new Date ();
}
2. Time and Days added
function Gettimeadddays {return to
new Date (Time.gettime () + days * * * 1000);
}
3. Get and format date: year-month-day
function Getformatdate (time) {return
time.getfullyear () + "-" + (Time.getmonth () + 1) + "-" + time.getdate ();
}
4. String conversion to date, string format: 2011-11-20
function Converttodate (strings) {return
new Date (Date.parse strings.replace ("-", "/"));
}
5. Get and format the week
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; Week
function Getformatweek (time) {return
weekdays[time.getday ()];
}
6. Time Comparison
function Comparetime (time1, time2) {return
time1.gettime ()-time2.gettime ();
}
7. Calculate the number of days between two dates
function GetDays (time1, tiem2) {
var day = 24*60*60*1000;
Return (Time1.gettime ()-Time2.gettime ())/day;
}
Small series for you to sum up seven aspects of JS in time processing knowledge, I hope to help you!