Date and Time Functions

JavaScript’s character and string function is incorporated into the Date Object. The Date object can be used to carry out many different date and time manipulations.

In order to use the properties and methods of Date the Date must be created. Date objects are created using new Date(), e.g.

var Thedate = new Date();
var Day = Thedate.getDate();
alert (Day);

This code will display today’s date.

var Thedate = new Date();
var Month = Thedate.getMonth();
alert (Month);

This code will display the month.

Examples of Date usage are setting the date and time and finding the day, month, year and time from the system. There are many other Date functions available.

Next: Functions Quiz