Thursday, July 10, 2008

Date Object in JavaScript

Date Object in JavaScript

Method Description
Date() Returns today's date and time
getDate() Returns the day of the month from a Date object (from 1-31)
getDay() Returns the day of the week from a Date object (from 0-6)
getMonth() Returns the month from a Date object (from 0-11)
getFullYear() Returns the year, as a four-digit number, from a Date object
getYear() Returns the year, as a two-digit or a three/four-digit number, depending on the browser. Use getFullYear() instead !!
getHours() Returns the hour of a Date object (from 0-23)
getMinutes() Returns the minutes of a Date object (from 0-59)
getSeconds() Returns the seconds of a Date object (from 0-59)
getMilliseconds() Returns the milliseconds of a Date object (from 0-999)
getTime() Returns the number of milliseconds since midnight Jan 1, 1970
getTimezoneOffset() Returns the difference in minutes between local time and Greenwich Mean Time (GMT)
getUTCDate() Returns the day of the month from a Date object according to universal time (from 1-31)
getUTCDay() Returns the day of the week from a Date object according to universal time (from 0-6)
getUTCMonth() Returns the month from a Date object according to universal time (from 0-11)
getUTCFullYear() Returns the four-digit year from a Date object according to universal time
getUTCHours() Returns the hour of a Date object according to universal time (from 0-23)
getUTCMinutes() Returns the minutes of a Date object according to universal time (from 0-59)
getUTCSeconds() Returns the seconds of a Date object according to universal time (from 0-59)
getUTCMilliseconds() Returns the milliseconds of a Date object according to universal time (from 0-999)
parse() Takes a date string and returns the number of milliseconds since midnight of January 1, 1970
setDate() Sets the day of the month in a Date object (from 1-31)
setMonth() Sets the month in a Date object (from 0-11)
setFullYear() Sets the year in a Date object (four digits)
setYear() Sets the year in the Date object (two or four digits). Use setFullYear() instead !!
setHours() Sets the hour in a Date object (from 0-23)
setMinutes() Set the minutes in a Date object (from 0-59)
setSeconds() Sets the seconds in a Date object (from 0-59)
setMilliseconds() Sets the milliseconds in a Date object (from 0-999)
setTime() Calculates a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970
setUTCDate() Sets the day of the month in a Date object according to universal time (from 1-31)
setUTCMonth() Sets the month in a Date object according to universal time (from 0-11)
setUTCFullYear() Sets the year in a Date object according to universal time (four digits)
setUTCHours() Sets the hour in a Date object according to universal time (from 0-23)
setUTCMinutes() Set the minutes in a Date object according to universal time (from 0-59)
setUTCSeconds() Set the seconds in a Date object according to universal time (from 0-59)
setUTCMilliseconds() Sets the milliseconds in a Date object according to universal time (from 0-999)
toSource() Represents the source code of an object
toString() Converts a Date object to a string
toGMTString() Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead !!
toUTCString() Converts a Date object, according to universal time, to a string
toLocaleString() Converts a Date object, according to local time, to a string
UTC() Takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time

No comments: