JavaScript Date object can also be used to get the Date parts or Time parts. To get the date, day, month and year separately you have to define the Date object with new keyword. This will provide you various functions to get the Date and Time in JavaScript.

JavaScript Date Object Methods to get date parts

getDate() getDate function returns the current date from 1 to 31 according to the corresponding month.

getDay() getDay function returns the current Day of the week from 0 to 6 where 0 for Sunday, 1 for Monday and so on.

getMonth() getMonth function returns the current month from 0 to 11 where 0 for January, 1 for February and so on.

getFullYear() getFullYear function returns the current year e.g. 2008

JavaScript Examples to get the parts of Date

// Date object defined with new keyword.
var myDate = new Date();

//  javaScript getDate function
document.write(myDate.getDate());

//  javaScript getDay function
document.write(myDate.getDay());

//  javaScript getMonth function
document.write(myDate.getMonth());

//  javaScript getFullYear function
document.write(myDate.getFullYear());

Continue to next tutorial: JavaScript Date Object Time functions to learn Time functions provided by Javascript Date Object.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.