Enables basic storage and retrieval of dates and times.
SyntaxdateObj = new Date()
dateObj = new Date( dateVal )
dateObj = new Date( year , month , date [, hours [, minutes [, seconds [, ms ]]]])
The following example illustrates the use of the Date object.
var dateString = "Today's date is: ";
var newDate = new Date();
dateString += (newDate.getMonth() + 1) + "/";
dateString += newDate.getDate() + "/";
dateString += newDate.getFullYear();
document.write(dateString);
Remarks
A Date object contains a number representing a particular instant in time to within a millisecond. If the value of an argument is greater than its range or is a negative number, other stored values are modified accordingly. For example, if you specify 150 seconds, JavaScript redefines that number as two minutes and 30 seconds.
If the number is NaN , the object does not represent a specific instant of time. If you pass no parameters to the Date object, it is initialized to the current time (UTC). A value must be given to the object before you can use it.
The range of dates that can be represented in a Date object is approximately 285,616 years on either side of January 1, 1970.
See Date and Time Calculations (Windows Scripting - JScript) for more information about how to use the Date object and related methods.
PropertiesThe following table lists the properties of the Date object.
FunctionsThe following table lists the functions of the Date object.
MethodsThe following table lists the methods of the Date object.
Method Summary getDate Gets the day-of-the-month, using local time. getDay Gets the day of the week, using local time. getFullYear Gets the year, using local time. getHours Gets the hours in a date, using local time. getMilliseconds Gets the milliseconds of a Date, using local time. getMinutes Gets the minutes of a Date object, using local time. getMonth Gets the month, using local time. getSeconds Gets the seconds of a Date object, using local time. getTime Gets the time value in milliseconds. getTimezoneOffset Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). getUTCDate Gets the day-of-the-month, using Universal Coordinated Time (UTC). getUTCDay Gets the day of the week using Universal Coordinated Time (UTC). getUTCFullYear Gets the year using Universal Coordinated Time (UTC). getUTCHours Gets the hours value in a Date object using Universal Coordinated Time (UTC). getUTCMilliseconds Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). getUTCMinutes Gets the minutes of a Date object using Universal Coordinated Time (UTC). getUTCMonth Gets the month of a Date object using Universal Coordinated Time (UTC). getUTCSeconds Gets the seconds of a Date object using Universal Coordinated Time (UTC). getYear Gets the year of a Date object. Deprecated in favor of getFullYear method. setDate Sets the numeric day-of-the-month value of the Date object using local time. setFullYear Sets the year of the Date object using local time. setHours Sets the hour value in the Date object using local time. setMilliseconds Sets the milliseconds value in the Date object using local time. setMinutes Sets the minutes value in the Date object using local time. setMonth Sets the month value in the Date object using local time. setSeconds Sets the seconds value in the Date object using local time. setTime Sets the date and time value in the Date object. setUTCDate Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). setUTCFullYear Sets the year value in the Date object using Universal Coordinated Time (UTC). setUTCHours Sets the hours value in the Date object using Universal Coordinated Time (UTC). setUTCMilliseconds Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). setUTCMinutes Sets the minutes value in the Date object using Universal Coordinated Time (UTC). setUTCMonth Sets the month value in the Date object using Universal Coordinated Time (UTC). setUTCSeconds Sets the seconds value in the Date object using Universal Coordinated Time (UTC). setYear Sets the year value in the Date object. Deprecated in favor of the setFullYear method. toDateString Returns the date component of a date as a human readable string. toGMTString Returns a date converted to a string formatted according to GMT conventions. toISOString Returns a date as a string value in simplified ISO 8601 Extended format. toLocaleDateString Returns a date as a string value appropriate to the host environment’s current locale. toTimeString Returns the time component of a date as a human readable string. toUTCString Returns a date converted to a string formatted according to UTC conventions. valueOf Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. hasOwnProperty Determines whether an object has a property with the specified name. isPrototypeOf Determines whether an object exists in another object’s prototype chain. PropertiesThe following table lists properties of the Date Object.
Property Description constructor Specifies the function that creates an object. prototype Returns a reference to the prototype for a class of objects. FunctionsThe following table lists functions of the Date Object.
Functions Description Date.now Returns the number of milliseconds between January 1, 1970, and the current date and time. Date.parse Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. Date.UTC Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the supplied date. AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4