Method |
Description |
Date () |
Returns the date and time of the current day. |
Getdate () |
Get the current day (1-31) |
Getday () |
Obtain the day of the week (0-6) |
Getmonth () |
Get month (0-11) |
Getfullyear () |
Obtain the complete year |
Getyear () |
Get year |
Gethours () |
Obtain the hour (0-23) |
Getminutes () |
Get minutes (0-59) |
Getseconds () |
Obtain seconds (0-59) |
Getmilliseconds () |
Obtain Millisecond (0-999) |
Gettime () |
Get the number of milliseconds from 1970.1.1 to the present |
Parse () |
Obtains the number of milliseconds from midnight to the specified date in 1970.1.1. |
Setdate () |
Set days |
Setmonth () |
Set month |
Setfullyear () |
Set the complete year |
Setyear () |
Set year |
Sethours () |
Set hours |
Setminutes () |
Set score |
Setseconds () |
Set seconds |
Setmilliseconds () |
Set millisecond |
Settime () |
Calculated by adding or subtracting the specified number of milliseconds from the midnight value in 1970.1.1 |
Tostring () |
Converts a date () object to a string. |
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
// Use the specified year, month, or day to create a date object
// Var date = new date (1988,10, 11 );
// Document. Write (date. getyear (); // output 88 (cause: Get the difference between the year and the month)
// Document. Write (date. getfullyear (); // output 1988
VaR date = new date (); // create the current date object
VaR year = date. getfullyear ();
VaR month = date. getmonth ();
VaR day = date. getdate ();
VaR hour = date. gethours ();
Hour = hour <10? "0" + hour: hour;
VaR minute = date. getminutes ();
Minute = minute <10? "0" + minute: minute;
VaR second = date. getseconds ();
Second = Second <10? "0" + Second: second;
Document. Write (Year + "-" + (month + 1) + "-" + day + "" + hour + ":" + minute + ":" + second );
If (hour <13 ){
Document. Write ("<br> am ");
} Else {
Document. Write ("<br> PM ");
}
Document. Write ("<br> Week" + date. getday ());
</SCRIPT>