10/3/13
JavaScript Date Object
Search w3schools.com: Select Language
HOME
HTML
C SS
JAVASC RIPT
JQUERY
XML
ASP.NET
PHP
SQL
MORE...
R EFER ENC ES
EXAMPLES
FO R UM
ABO UT
SoftLayer Official Site
SoftLaye r.com /Asia-Pacific
SHARE THIS PAGE
More C ustom Hosting From A Trusted Source. 24x7 Support. C hat Now.
Like
87k
JavaScript Reference
Overview
JavaScript Date Object
Previous Next Reference
WEB HOSTING
Best Web Hosting eUK Web Hosting UK Reseller Hosting Domain, Hosting & Email Lowest Price Hosting
JavaScript Objects
JS Array JS Boolean JS Date JS Math JS Number JS String JS RegExp JS Global
Date Object
The Date object is used to work with dates and times. Date objects are created with new Date(). There are four ways of instantiating a date:
WEB BUILDING
XML Editor - Free Trial! FREE Website BUILDER FREE Website C reator Best Website Templates
Browser Objects
Window Navigator Screen History Location
v a rd=n e wD a t e ( ) ; v a rd=n e wD a t e ( m i l l i s e c o n d s ) ; v a rd=n e wD a t e ( d a t e S t r i n g ) ; v a rd=n e wD a t e ( y e a r ,m o n t h ,d a y ,h o u r s ,m i n u t e s ,s e c o n d s ,m i l l i s e c o n d s ) ;
For a tutorial about date and times, read our JavaScript Date Object tutorial.
Date Object Properties
Property constructor prototype Description Returns the function that created the Date object's prototype Allows you to add properties and methods to an object
STATISTICS
Browser Statistics OS Statistics Display Statistics
HTML DOM Objects
DOM Document DOM Elements DOM Attributes DOM Events
Date Object Methods
Method getDate() getDay() getFullYear() getHours() getMilliseconds() getMinutes() getMonth() getSeconds() getTime() getTimezoneOffset() getUTCDate() getUTCDay() getUTCFullYear() getUTCHours() getUTCMilliseconds() getUTCMinutes() getUTCMonth() getUTCSeconds() getYear() parse() Description Returns the day of the month (from 1-31) Returns the day of the week (from 0-6) Returns the year (four digits) Returns the hour (from 0-23) Returns the milliseconds (from 0-999) Returns the minutes (from 0-59) Returns the month (from 0-11) Returns the seconds (from 0-59) Returns the number of milliseconds since midnight Jan 1, 1970 Returns the time difference between UTC time and local time, in minutes Returns the day of the month, according to universal time (from 1-31) Returns the day of the week, according to universal time (from 0-6) Returns the year, according to universal time (four digits) Returns the hour, according to universal time (from 0-23) Returns the milliseconds, according to universal time (from 0-999) Returns the minutes, according to universal time (from 0-59) Returns the month, according to universal time (from 0-11) Returns the seconds, according to universal time (from 0-59) Deprecated. Use the getFullYear() method instead Parses a date string and returns the number of milliseconds since midnight of January 1, 1970 Sets the day of the month of a date object Sets the year (four digits) of a date object Sets the hour of a date object
A ds by s afes aver
HTML Objects
DOM Anchor DOM Area DOM Base DOM Body DOM Button DOM Form DOM Frame/IFrame DOM Frameset DOM Image DOM Input Button DOM Input Checkbox DOM Input File DOM Input Hidden DOM Input Password DOM Input Radio DOM Input Reset DOM Input Submit DOM Input Text DOM Link DOM Meta DOM Object DOM Option DOM Select DOM Style DOM Table DOM td / th DOM tr DOM Textarea
setDate() setFullYear() setHours()
www.w3schools.com/jsref/jsref_obj_date.asp
1/3
10/3/13
setHours() setMilliseconds() setMinutes() setMonth() setSeconds() setTime()
Sets the hour of a date object
JavaScript Date Object
Sets the milliseconds of a date object Set the minutes of a date object Sets the month of a date object Sets the seconds of a date object Sets a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970 Sets the day of the month of a date object, according to universal time Sets the year of a date object, according to universal time (four digits) Sets the hour of a date object, according to universal time Sets the milliseconds of a date object, according to universal time Set the minutes of a date object, according to universal time Sets the month of a date object, according to universal time Set the seconds of a date object, according to universal time Deprecated. Use the setFullYear() method instead Converts the date portion of a Date object into a readable string Deprecated. Use the toUTCString() method instead Returns the date as a string, using the ISO standard Returns the date as a string, formatted as a JSON date Returns the date portion of a Date object as a string, using locale conventions Returns the time portion of a Date object as a string, using locale conventions Converts a Date object to a string, using locale conventions Converts a Date object to a string Converts the time portion of a Date object to a string Converts a Date object to a string, according to universal time Returns the number of milliseconds in a date string since midnight of January 1, 1970, according to universal time Returns the primitive value of a Date object
setUTCDate() setUTCFullYear() setUTCHours() setUTCMilliseconds() setUTCMinutes() setUTCMonth() setUTCSeconds() setYear() toDateString() toGMTString() toISOString() toJSON() toLocaleDateString() toLocaleTimeString() toLocaleString() toString() toTimeString() toUTCString() UTC()
valueOf()
Previous
Next Reference
A ds by s afes aver
Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial
Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors
Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples jQuery Examples XML DOM Examples AJAX Examples Razor Examples ASP Examples SVG Examples
Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz
Color Picker
Statistics
Browser Statistics Browser OS Browser Display
RE P O RT E RRO R
HO ME
TO P
P RI N T
FO RU M
A BO U T
A D V E RT I SE WI T H U S
www.w3schools.com/jsref/jsref_obj_date.asp
2/3
10/3/13
JavaScript Date Object
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2013 by Refsnes Data. All Rights Reserved.
www.w3schools.com/jsref/jsref_obj_date.asp
3/3