Date objects are used to process dates and times. the JavaScript Date Object instance returns how the date and time of day is used to obtain the date of the day using the date () method. GetTime () GetTime () returns the number of milliseconds since January 1, 1970. setFullYear () How to set a specific date using setfullyear (). toUTCString () How to use toUTCString () to convert the date of day (based on UTC) to a string. Getday () How to use the Getday () and array to display weeks, not just numbers. Shows how a clock displays a clock on the page. complete Date Object reference manual
We provide a JavaScript Date object reference manual that includes all of the properties and methods available for date objects.
The manual contains a detailed description of each property and method and a related instance. Define Date
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 ()
Note: A Date object automatically uses the current date and time as its initial value. Operation Date
By using a method for date objects, we can easily manipulate dates.
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 parameters that represent the month are between 0 and 11. In other words, if you want to set the month to August, the argument should be 7.
In the following example, we set the Date object to the date after 5 days:
var mydate=new Date ()
mydate.setdate (Mydate.getdate () +5)
Note: If increasing the number of days changes the month or year, the date object automatically completes the conversion. Compare Date
Date objects can also be used to compare two dates.
The following code compares the current date with the August 9, 2008:
var mydate=new Date ();
Mydate.setfullyear (2008,8,9);
var today = new Date ();
if (mydate>today)
{
alert ("Today is before 9th August 2008");
}
else
{
alert ("Today was after 9th August 2008");
}