Tutorials » Javascript tutorials »

The Date Object

This article explains about the JavaScript Date object

The other important JavaScript object is Date Object. In order to work with date and time it’s used. As all of us know that JavaScript is a client side language and the script runs on the client, therefore it will always return the date/time of the client. You can use date object to display a "countdown," such as the number of days left
for the favorite movie to release .

Instantiating Date Object can be done on either of these ways.

new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month, day, hours, minutes, seconds, milliseconds) //most parameters here are optional. Not specifying causes 0 to be passed in.


day = new Date()
day = new Date("August15, 2006 08:25:00")
day = new Date(06,8,15)
day = new Date(06,8,15,8,25,0)


• getHours() - Returns the hour
• getMinutes() - Returns the minutes
• getSeconds() - Returns the seconds
• getYear() - Returns the year ("06" is 2006)
• getMonth() - Returns the month ( returns "0" is if month is January)
• getDate() - Returns the day of the month
• getDay() - Returns the day of the week ( returns "0" is if week is Sunday)

Next Chapter: Date object's' getDate() method
Previous Chapter: The string Object
More Chapters: Javascript Tutorials
More Tutorials: Tutorial Index

Top Contributors
TodayLast 7 Daysmore...

Awards & Gifts

Online Members

Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India