www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons JavaScript Date Object Functions and Properties Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Lesson 45
Lesson 46
Lesson 47
Lesson 48
Lesson 49
The built-in Date object of JavaScript allows us to work with dates and times in our JavaScript programs. The Date object is used to store and retrieve dates in JavaScript. The Date object is created using the following syntax:

var dt = new Date();

The Date class is a very useful one in JavaScript. The above line of code creates a new Date object with the value of the current date and time of the machine, where the code is running.

The following table summarizes the Date object's funcitons:
Function Description Returns
getDate()
getUTCDate()
Day of the month 1-31
getDay()
getUTCDay()
Day of the week (integer) 0-6
getFullYear()
getUTCFullYear()
Year (full four digit) 1900+
getHours()
getUTCHours()
Hour of the day (integer) 0-23
getMilliseconds()
getUTCMilliseconds()
Milliseconds (since last second) 0-999
getMinutes()
getUTCMinutes()
Minutes (since last hour) 0-59
getMonth()
getUTCMonth()
Month 0-11
getSeconds()
getUTCSeconds()
Seconds (since last minute) 0-59
getTime() Number of milliseconds since 1 January 1970  
getTimezoneOffset() Difference between local time and GMT in minutes 0-1439
getYear() Year 0-99 for years between 1900-1999
Four digit for 2000+
parse() Returns the number of milliseconds since midnight 1 January 1970 for a given date and time.  
setDate()
setUTCDate()
Sets the day, given a number between 1-31 Date in milliseconds
setFullYear()
setUTCFullYear()
Sets the year, given a four digit number Date in milliseconds
setHours()
setUTCHours()
Sets the hour, given a number between 0-23 Date in milliseconds
setMilliseconds()
setUTCMilliseconds()
Sets the milliseconds, given a number Date in milliseconds
setMinutes()
setUTCMinutes()
Sets the minutes, given a number between 0-59 Date in milliseconds
setMonth()
setUTCMonth()
Sets the month, given a number between 0-11 Date in milliseconds
setSeconds()
setUTCSeconds()
Sets the seconds,l given a number between 0-59 Date in milliseconds
setTime() Sets the date, given the number of milliseconds since 1 January 1970 Date in milliseconds
setYear() Sets the year, given either a two digit or four digit number Date in milliseconds
toGMTString()
toUTCString()
GMT date and time as a string day dd mmm yyyy hh:mm:ss GMT
toLocaleString() Local date and time as a string Depends on operating system, locale, and browser
toString() Local date and time as a string Depends on operating system, locale, and browser
UTC() Returns the number of milliseconds since 1 January 1970 for a given date in year, month, day (and optionally, hours, minutes, seconds, and milliseconds) Date in milliseconds
valueOf() Number of milliseconds since 1 January 1970 Date in milliseconds
GMT is short form of Greenwich Mean Time.

UTC is short form of Universal Coordinated Time. which is set by the World Time Standard.


Next >>> Lesson No. 35: JavaScript Math Object







Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.