Date Object

eSignal EFS 2

Date Object

Top  Previous  Next

 

The Date  Object in Javascript

 

Date Constructors

 

       var newDateObject = new Date();

       var newDateObject = new Date(dateValue);

       var newDateObject = new Date(year, month, day, [hours], [minutes], [seconds], [milliseconds]);

       var newDateObject = new Date(year, month, day);

       var newDateObject = new Date(year month, day, hour, minutes, seconds);

 

If dateValue is a numeric value, it represents the number of milliseconds since January 1, 1970 00:00:00. The ranges of dates is approximately 285,616 years from either side of midnight. Negative numbers indicate dates prior to 1970.

 

·Year: The full year (1980).
·Month: 0-11 (January to December)
·Day: 1-31
·Hour: 0-23
·Minutes: 0-59
·Seconds: 0-59
·Milliseconds: 0-999

 

Remarks

 

Once the date object is constructed, methods can be accessed by the following syntax:

 

       var today = new Date();

       var h = today.getHours();

       var s = today.toString();

 

·Local Time is defined as: the time on the computer from where the script is executed.
·UTC (Universal Coordinated Time) refers to the time as set by the World Time Standard. Also known as GMT (Greenwich Mean Time).

 

 

Date Methods

 

getDate()

returns the day of the month of the date object according to local time

getDay()

returns the day of the week of the date object where 0 = Sunday

getFullYear()

returns the year of the date object according to local time

getHours()

returns the hour of the date object according to local time

getMilliseconds()

returns the milliseconds of the date object according to local time

getMinutes()

returns the minutes of the date object according to local time

getMonth()

returns the month of the date object according to local time

getSeconds()

returns the seconds of the date object according to local time

getTime()

returns the number of milliseconds since 1/1/1970 according to local time. negative numbers indicate a date prior to 1/1/1970

getTimezoneOffset()

returns the timezone offset between local time and GMT

getUTCDate()

returns the day of the month of the date object according to UTC

getUTCDay()

returns the day of the week of the date object according to UTC. 0 = Sunday

getUTCFullYear()

returns the year of the date object according to UTC

getUTCHours()

returns the hours of the date object according to UTC

getUTCMilliseconds()

returns the milliseconds of the date object according to UTC

getUTCMinutes()

returns the minutes of the date object according to UTC

getUTCMonth()

returns the month of the date object according to UTC

getUTCSeconds()

returns the seconds of the date object according to UTC

getYear()

returns a two digit representation of the year in the date object

parse(dateString)

returns the number of milliseconds in dateString since 1/1/1970 local time

setDate(domValue)

set the day of the month of this date object according to local time

setFullYear(yearValue, [monthValue][, [domValue] ])

set the year of this date object according to local time

setHours(hourValue, [minuteValue] [, [secondsValue] [, [millisecondsValue]]] )

set the hour of this date object according to local time

setMilliseconds(millisecondValue)

set the milliseconds of this date object according to local time

setMinutes(minuteValue)

set the minutes of this date object according to local time

setMonth(monthValue)

set the month of this date object according to local time

setSeconds(secondValue, [millisecondsValue])

set the seconds of this date object according to local time

setTime(millisecondsValue)

set the number of milliseconds since 1/1/1970 according to local time

setUTCDate(domValue)

set the day of the month of this date object according to UTC

setUTCFullYear(yearValue, [monthValue] [, [domValue]])

set the year of this date object according to UTC