new DateTime(year, month, day)

Initializes a new instance of the DateTime object to the specified year, month, and day.

Parameters

Name Type Optional Description

year

 

 

The year (1 through 9999).

month

 

 

The month (1 through 12).

day

 

 

The day (1 through the number of days in month).

Methods

static

getNow() → DateTime

Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.

Returns

DateTime A DateTime object whose value is the current local date and time.

addDays(value) → DateTime

Adds the specified number of days to the value of this instance.

Parameter

Name Type Optional Description

value

Number

 

A number of whole and fractional days. The value parameter can be negative or positive.

Returns

DateTime A DateTime object whose value is the sum of the date and time represented by this instance and the number of days represented by value.

addHours(value) → DateTime

Adds the specified number of hours to the value of this instance.

Parameter

Name Type Optional Description

value

Number

 

A number of whole and fractional hours. The value parameter can be negative or positive.

Returns

DateTime A DateTime object whose value is the sum of the date and time represented by this instance and the number of hours represented by value.

addMilliseconds(value) → DateTime

Adds the specified number of milliseconds to the value of this instance.

Parameter

Name Type Optional Description

value

Number

 

A number of whole and fractional milliseconds. The value parameter can be negative or positive. Note that this value is rounded to the nearest integer.

Returns

DateTime A DateTime object whose value is the sum of the date and time represented by this instance and the number of milliseconds represented by value.

addMinutes(value) → DateTime

Adds the specified number of minutes to the value of this instance.

Parameter

Name Type Optional Description

value

Number

 

A number of whole and fractional minutes. The value parameter can be negative or positive.

Returns

DateTime A DateTime object whose value is the sum of the date and time represented by this instance and the number of minutes represented by value.

addMonths(months) → DateTime

Adds the specified number of months to the value of this instance.

Parameter

Name Type Optional Description

months

Number

 

A number of months. The months parameter can be negative or positive.

Returns

DateTime A DateTime object whose value is the sum of the date and time represented by this instance and months.

addSeconds(value) → DateTime

Adds the specified number of seconds to the value of this instance.

Parameter

Name Type Optional Description

value

Number

 

A number of whole and fractional seconds. The value parameter can be negative or positive.

Returns

DateTime A DateTime object whose value is the sum of the date and time represented by this instance and the number of seconds represented by value.

addYears(value) → DateTime

Adds the specified number of years to the value of this instance.

Parameter

Name Type Optional Description

value

Number

 

A number of years. The value parameter can be negative or positive.

Returns

DateTime A DateTime object whose value is the sum of the date and time represented by this instance and the number of years represented by value.

compareTo(value) → Number

Compares the value of this instance to a specified object that contains a specified DateTime value, and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.

Parameter

Name Type Optional Description

value

Object

 

A boxed DateTime object to compare, or null.

Returns

Number A signed number indicating the relative values of this instance and value. Value Description Less than zero This instance is earlier than value. Zero This instance is the same as value. Greater than zero This instance is later than value, or value is null.

compareTo(value) → Number

Compares the value of this instance to a specified DateTime value and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.

Parameter

Name Type Optional Description

value

DateTime

 

A DateTime object to compare.

Returns

Number A signed number indicating the relative values of this instance and the value parameter. Value Description Less than zero This instance is earlier than value. Zero This instance is the same as value. Greater than zero This instance is later than value.

constructor_overload$1(year, month, day, hour, minute, second)

Initializes a new instance of the DateTime object to the specified year, month, day, hour, minute, and second.

Parameters

Name Type Optional Description

year

Number

 

The year (1 through 9999).

month

Number

 

The month (1 through 12).

day

Number

 

The day (1 through the number of days in month).

hour

Number

 

The hours (0 through 23).

minute

Number

 

The minutes (0 through 59).

second

Number

 

The seconds (0 through 59).

constructor_overload$2(year, month, day, hour, minute, second, millisecond)

Initializes a new instance of the DateTime object to the specified year, month, day, hour, minute, second, and millisecond.

Parameters

Name Type Optional Description

year

Number

 

The year (1 through 9999).

month

Number

 

The month (1 through 12).

day

Number

 

The day (1 through the number of days in month).

hour

Number

 

The hours (0 through 23).

minute

Number

 

The minutes (0 through 59).

second

Number

 

The seconds (0 through 59).

millisecond

Number

 

The milliseconds (0 through 999).

constructor_overload$3(date)

Initializes a new instance of the DateTime object to the specified Date object

Parameter

Name Type Optional Description

date

Date

 

The Date object

constructor_overload$4(cld)

Initializes a new instance of the DateTime object to the specified Calendar object

Parameter

Name Type Optional Description

cld

Calendar

 

The Calendar object

equals(value) → boolean

Returns a value indicating whether this instance is equal to a specified object.

Parameter

Name Type Optional Description

value

Object

 

An object to compare to this instance.

Returns

boolean true if value is an instance of DateTime and equals the value of this instance; otherwise, false.

getDay() → Number

Gets the day of the month represented by this instance.

Returns

Number The day component, expressed as a value between 1 and 31.

getDayOfWeek() → Number

Gets the day of the week represented by this instance.

Returns

Number the day of the week of this DateTime value.

getDayOfYear() → Number

Gets the day of the year represented by this instance.

Returns

Number The day of the year, expressed as a value between 1 and 366.

getHour() → Number

Gets the hour component of the date represented by this instance.

Returns

Number The hour component, expressed as a value between 0 and 23.

getMillisecond() → Number

Gets the milliseconds component of the date represented by this instance.

Returns

Number The milliseconds component, expressed as a value between 0 and 999.

getMinute() → Number

Gets the minute component of the date represented by this instance.

Returns

Number The minute component, expressed as a value between 0 and 59.

getMonth() → Number

Gets the month component of the date represented by this instance.

Returns

Number The month component, expressed as a value between 1 and 12.

getSecond() → Number

Gets the seconds component of the date represented by this instance.

Returns

Number The seconds, between 0 and 59.

getYear() → Number

Gets the year component of the date represented by this instance.

Returns

Number The year, between 1 and 9999.

hashCode() → Number

Returns the hash code for this instance.

Returns

Number A 32-bit signed integer hash code.

toCalendar() → Calendar

Converts the value of the current DateTime object to Calendar object.

Returns

Calendar Calendar object

toDate() → Date

Converts the value of the current DateTime object to Date object.

Returns

Date Date object

toLocalTime() → DateTime

Converts the value of the current DateTime object to local time.

Returns

DateTime A DateTime object of local

toString() → String

Converts the value of the current DateTime object to its equivalent string representation.

Returns

String A string representation of the value of the current DateTime object.

toUniversalTime() → DateTime

Converts the value of the current DateTime object to Coordinated Universal Time(UTC).

Returns

DateTime A DateTime object of UTC