**1. Defining Dates * *
The Date object is used to process dates and times.
You can define a Date object by using the New keyword. The following code defines a Date object named MyDate:
var mydate=new Date ()
----------
**2. Operation Date * *
By using a method for a Date object, we can easily manipulate the date.
In the following example, we set a specific date for the Date object (August 9, 2008):
var mydate=new Date ()
Mydate.setfullyear (2008,7,9)
Note: The parameter that represents the month is between 0 and 11. That is, if you want to set the month to August, the parameter should be 7.
----------
In the following example, we set the Date object to a date after 5 days:
var mydate=new Date ()
Mydate.setdate (Mydate.getdate () +5)
Note: If you increase the number of days to change the month or year, the Date object will automatically complete the conversion.
----------
**4.math Object * * *
The Math object works by performing normal arithmetic tasks.
The Math object provides a variety of arithmetic value types and functions. You do not need to define it before using this object.
5.
* * Function (method) * *
Instance:
The following example rounds a number by using the round method of the Math object.
document.write (Math.Round (4.7)) The above code output is:
5 The following example uses the Math object's random () method to return an arbitrary number between 0 and 1:
The code output above document.write (Math.random ()) is:
0.9370844220218102 The following example uses the floor () method and random () of the Math object to return a random number between 0 and 10:
document.write (Math.floor (Math.random () *11))
----------
**6.math Object Methods * *
ABS (x): The absolute value of the returned number.
Ceil (x): Rounding on a logarithmic.
Floor (x): The logarithm is rounded down.
Max (x, y): Returns the highest value in X and Y.
Min (x, y): Returns the lowest value in X and Y.
Random (): Returns the number of randomly between 0 and 1.
Round (x): rounds the number to the nearest integer.
----------
**7.date Object Methods * *
Date (): Returns the day and time.
GetDate (): Returns the day of the one month (1 ~ 31) from the Date object.
GetDay (): Returns the day of the week (0 ~ 6) from the Date object.
GetMonth (): Returns the month (0 ~ 11) from the Date object.
getFullYear (): Returns the year as a four-digit number from a Date object.
GetYear (): Please use the getFullYear () method instead.
GetHours (): Returns the hour of the Date object (0 ~ 23).
Getminutes (): Returns the minute of the Date object (0 ~ 59).
Getseconds (): Returns the number of seconds (0 ~ 59) of the Date object.
Getmilliseconds (): Returns the milliseconds (0 ~ 999) of the Date object.
GetTime (): Returns the number of milliseconds since January 1, 1970.
Date and Math