ADVERTISEMENT
ADVERTISEMENT

JavaScript Date Object Methods

In JavaScript, the Date object is used to work with the date & time.

JavaScript Date Object Methods: This section contains various Date object properties and methods with examples.

List of JavaScript Date Object Properties & Methods

Property/Method Description
Date constructor It returns the details of the Date's class constructor function.
getDate() It returns the current day of the month.
getDay() It returns the current day of the week.
getMonth() It returns the value of the month from the current date.
getFullYear() It returns the current full year in 4 digits format.
getHours() It returns the only hours from current time.
getMinutes() It returns the only minutes from the current time.
getSeconds() It returns the only seconds from the current time.
getMilliseconds() It returns the only milliseconds from the current time.
getTime() It returns the time in milliseconds from 1st January 1970.
getTimezoneOffset() It returns the the timezone difference between UTC and local time.
getUTCDate() It returns the current day of the month according to the UTC (Universal time coordinated).
getUTCDay() It returns the current day of the week according to the UTC (Universal time coordinated). It returns the value between 0 to 6 based on the day. 0 for Sunday, 1 for Monday... 6 for Saturday.
getUTCMonth() It returns the current month’s value according to the UTC (Universal time coordinated) between the range of 0 to 11, where 0 for January, 1 for February, ..., 11 for December.
getUTCFullYear() It returns the current year in the format of 4 digits according to the UTC (Universal time coordinated).
getUTCHours() It returns the hours from the current time according to the UTC (Universal time coordinated).
getUTCMinutes() It returns the minutes from the current time according to the UTC (Universal time coordinated).
getUTCSeconds() It returns the seconds from the current time according to the UTC (Universal time coordinated).
getUTCMilliseconds() It returns the milliseconds from the current time according to the UTC (Universal time coordinated).
now() It returns the current time in milliseconds, it returns the total number of milliseconds since 01st January 1970, 00:00:00 UTC.
parse() It parses a given date string and returns the total number of milliseconds since 01st January 1970 (midnight) to given date string.
setDate() It sets the current date (day of the month) to the Date object with a valid date value (between 1 to 31, based on the current month).
setMonth() It sets the month to the Date object with a valid month value (between 0 to 11. 0 for January, 1 for February and so on).
setFullYear() It sets the year (in 4 digits) to the Date object with a valid year value (between 1000 to 9999).
setHours() It sets the hour to the Date object with a valid hour value (between 00 to 23).
setMinutes() It sets the minutes to the Date object with a valid minute’s value (between 00 to 59).
setSeconds() It sets the seconds to the Date object with a valid second’s value (between 00 to 59).
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.