Sets the full year for a specified date according to local time. Sets the day of the month for a specified date according to local time. Returns the seconds in the specified date according to universal time.ĭeprecated - Returns the year in the specified date according to local time. Returns the month in the specified date according to universal time. Returns the minutes in the specified date according to universal time. Returns the milliseconds in the specified date according to universal time.
Returns the hours in the specified date according to universal time. Returns the year in the specified date according to universal time. Returns the day of the week in the specified date according to universal time. Returns the day (date) of the month in the specified date according to universal time. Returns the time-zone offset in minutes for the current locale. Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC. Returns the seconds in the specified date according to local time. Returns the month in the specified date according to local time. Returns the minutes in the specified date according to local time. Returns the milliseconds in the specified date according to local time. Returns the hour in the specified date according to local time. Returns the year of the specified date according to local time. Returns the day of the week for the specified date according to local time. Returns the day of the month for the specified date according to local time. Here is a list of the methods used with Date and their description. In the following sections, we will have a few examples to demonstrate the usage of different Date properties. The prototype property allows you to add properties and methods to an object Specifies the function that creates an object's prototype. Here is a list of the properties of the Date object along with their description. Millisecond − Integer value representing the millisecond segment of a time reading. Second − Integer value representing the second segment of a time reading. Minute − Integer value representing the minute segment of a time reading. Hour − Integer value representing the hour of the day (24-hour scale). Month − Integer value representing the month, beginning with 0 for January to 11 for December.ĭate − Integer value representing the day of the month. For compatibility (in order to avoid the Y2K problem), you should always specify the year in full use 1998, rather than 98. Year − Integer value representing the year. For example, passing the argument 5000 creates a date that represents five seconds past midnight on 1/1/70.ĭatestring − When one string argument is passed, it is a string representation of a date, in the format accepted by the Date.parse() method.ħ agruments − To use the last form of the constructor shown above. Milliseconds − When one numeric argument is passed, it is taken as the internal numeric representation of the date in milliseconds, as returned by the getTime() method. No Argument − With no arguments, the Date() constructor creates a Date object set to the current date and time. Here is a description of the parameters − Note − Parameters in the brackets are always optional. You can use any of the following syntaxes to create a Date object using Date() constructor.
This is a range of plus or minus 273,785 years, so JavaScript can represent date and time till the year 275755. The ECMAScript standard requires the Date object to be able to represent any date and time, to millisecond precision, within 100 million days before or after. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time. Once a Date object is created, a number of methods allow you to operate on it. Date objects are created with the new Date( ) as shown below. When initializing a date you can pass a timezone, so the date is not assumed UTC and then converted to your local timezone.The Date object is a datatype built into the JavaScript language. passing a set of parameters, which represent the different parts of a date.passing a string, which represents a date.passing a number, which represents the milliseconds from 00:00 GMT.passing no parameters, creates a Date object that represents “now”.So, summarizing, you can create a new Date object in 4 ways JavaScript, without any information about the timezone, will consider the date as UTC, and will automatically perform a conversion to the current computer timezone. This means that two different computers might output a different value for the same date object. In any of these cases, the resulting date is relative to the timezone of your computer.