DateTime

DateTime class that adds micro and nanoseconds.

Extends

  • DateTime

Constructors

  • constructor

    • new DateTime(): DateTime

      Returns DateTime

    • new DateTime(value: string | number): DateTime

      Returns DateTime

    • new DateTime(year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): DateTime

      Creates a new Date.

      Parameters

      • year: numberThe full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
      • monthIndex: numberThe month as a number between 0 and 11 (January to December).
      • date?: numberThe date as a number between 1 and 31.
      • hours?: numberMust be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
      • minutes?: numberMust be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
      • seconds?: numberMust be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
      • ms?: numberA number from 0 to 999 that specifies the milliseconds.

      Returns DateTime

    • new DateTime(value: string | number | Date): DateTime

      Returns DateTime

Methods

  • makeLocalDateTime

    • makeLocalDateTime(year: number, month: number, day: number, resolution: number, secondsInDay: number, subSecond: number): DateTime

      Returns DateTime

  • makeUtcDateTime

    • makeUtcDateTime(year: number, month: number, day: number, resolution: number, secondsInDay: number, subSecond: number): DateTime

      Returns DateTime

  • fromJSON

    • fromJSON(json: any): DateTime

      Make a DateTime from JSON from DateTime.toJSON().

      Returns DateTime

  • parse

    • parse(s: string): number

      Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970.

      Parameters

      • s: stringA date string

      Returns number

  • UTC

    • UTC(year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number

      Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.

      Parameters

      • year: numberThe full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
      • monthIndex: numberThe month as a number between 0 and 11 (January to December).
      • date?: numberThe date as a number between 1 and 31.
      • hours?: numberMust be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
      • minutes?: numberMust be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
      • seconds?: numberMust be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
      • ms?: numberA number from 0 to 999 that specifies the milliseconds.

      Returns number

  • now

    • now(): number

      Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).

      Returns number

  • toString

    • toString(): string

      Returns string

  • toLocaleString

    • toLocaleString(): string

      Returns string

  • getMicroseconds

    • getMicroseconds(): undefined | number

      Returns undefined | number

  • getNanoseconds

    • getNanoseconds(): undefined | number

      Returns undefined | number

  • toJSON

    • toJSON(): any

      Returns any

  • dateToString

    • dateToString(): string

      Returns string

  • timeToString

    • timeToString(): string

      Returns string

  • setLocalTime

    • setLocalTime(resolution: number, secondsInDay: number, subSecond: number): void

      Returns void

  • setUtcTime

    • setUtcTime(resolution: number, secondsInDay: number, subSecond: number): void

      Returns void

  • toDateString

    • toDateString(): string

      Returns a date as a string value.

      Returns string

  • toTimeString

    • toTimeString(): string

      Returns a time as a string value.

      Returns string

  • toLocaleDateString

    • toLocaleDateString(): string

      Returns a date as a string value appropriate to the host environment's current locale.

      Returns string

    • toLocaleDateString(locales?: string | string[], options?: DateTimeFormatOptions): string

      Converts a date to a string by using the current or specified locale.

      Parameters

      • locales?: string | string[]A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
      • options?: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.

      Returns string

    • toLocaleDateString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string

      Converts a date to a string by using the current or specified locale.

      Parameters

      • locales?: LocalesArgumentA locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
      • options?: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.

      Returns string

  • toLocaleTimeString

    • toLocaleTimeString(): string

      Returns a time as a string value appropriate to the host environment's current locale.

      Returns string

    • toLocaleTimeString(locales?: string | string[], options?: DateTimeFormatOptions): string

      Converts a time to a string by using the current or specified locale.

      Parameters

      • locales?: string | string[]A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
      • options?: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.

      Returns string

    • toLocaleTimeString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string

      Converts a time to a string by using the current or specified locale.

      Parameters

      • locales?: LocalesArgumentA locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
      • options?: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.

      Returns string

  • valueOf

    • valueOf(): number

      Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.

      Returns number

  • getTime

    • getTime(): number

      Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.

      Returns number

  • getFullYear

    • getFullYear(): number

      Gets the year, using local time.

      Returns number

  • getUTCFullYear

    • getUTCFullYear(): number

      Gets the year using Universal Coordinated Time (UTC).

      Returns number

  • getMonth

    • getMonth(): number

      Gets the month, using local time.

      Returns number

  • getUTCMonth

    • getUTCMonth(): number

      Gets the month of a Date object using Universal Coordinated Time (UTC).

      Returns number

  • getDate

    • getDate(): number

      Gets the day-of-the-month, using local time.

      Returns number

  • getUTCDate

    • getUTCDate(): number

      Gets the day-of-the-month, using Universal Coordinated Time (UTC).

      Returns number

  • getDay

    • getDay(): number

      Gets the day of the week, using local time.

      Returns number

  • getUTCDay

    • getUTCDay(): number

      Gets the day of the week using Universal Coordinated Time (UTC).

      Returns number

  • getHours

    • getHours(): number

      Gets the hours in a date, using local time.

      Returns number

  • getUTCHours

    • getUTCHours(): number

      Gets the hours value in a Date object using Universal Coordinated Time (UTC).

      Returns number

  • getMinutes

    • getMinutes(): number

      Gets the minutes of a Date object, using local time.

      Returns number

  • getUTCMinutes

    • getUTCMinutes(): number

      Gets the minutes of a Date object using Universal Coordinated Time (UTC).

      Returns number

  • getSeconds

    • getSeconds(): number

      Gets the seconds of a Date object, using local time.

      Returns number

  • getUTCSeconds

    • getUTCSeconds(): number

      Gets the seconds of a Date object using Universal Coordinated Time (UTC).

      Returns number

  • getMilliseconds

    • getMilliseconds(): number

      Gets the milliseconds of a Date, using local time.

      Returns number

  • getUTCMilliseconds

    • getUTCMilliseconds(): number

      Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).

      Returns number

  • getTimezoneOffset

    • getTimezoneOffset(): number

      Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC).

      Returns number

  • setTime

    • setTime(time: number): number

      Sets the date and time value in the Date object.

      Parameters

      • time: numberA numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.

      Returns number

  • setMilliseconds

    • setMilliseconds(ms: number): number

      Sets the milliseconds value in the Date object using local time.

      Parameters

      • ms: numberA numeric value equal to the millisecond value.

      Returns number

  • setUTCMilliseconds

    • setUTCMilliseconds(ms: number): number

      Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).

      Parameters

      • ms: numberA numeric value equal to the millisecond value.

      Returns number

  • setSeconds

    • setSeconds(sec: number, ms?: number): number

      Sets the seconds value in the Date object using local time.

      Parameters

      • sec: numberA numeric value equal to the seconds value.
      • ms?: numberA numeric value equal to the milliseconds value.

      Returns number

  • setUTCSeconds

    • setUTCSeconds(sec: number, ms?: number): number

      Sets the seconds value in the Date object using Universal Coordinated Time (UTC).

      Parameters

      • sec: numberA numeric value equal to the seconds value.
      • ms?: numberA numeric value equal to the milliseconds value.

      Returns number

  • setMinutes

    • setMinutes(min: number, sec?: number, ms?: number): number

      Sets the minutes value in the Date object using local time.

      Parameters

      • min: numberA numeric value equal to the minutes value.
      • sec?: numberA numeric value equal to the seconds value.
      • ms?: numberA numeric value equal to the milliseconds value.

      Returns number

  • setUTCMinutes

    • setUTCMinutes(min: number, sec?: number, ms?: number): number

      Sets the minutes value in the Date object using Universal Coordinated Time (UTC).

      Parameters

      • min: numberA numeric value equal to the minutes value.
      • sec?: numberA numeric value equal to the seconds value.
      • ms?: numberA numeric value equal to the milliseconds value.

      Returns number

  • setHours

    • setHours(hours: number, min?: number, sec?: number, ms?: number): number

      Sets the hour value in the Date object using local time.

      Parameters

      • hours: numberA numeric value equal to the hours value.
      • min?: numberA numeric value equal to the minutes value.
      • sec?: numberA numeric value equal to the seconds value.
      • ms?: numberA numeric value equal to the milliseconds value.

      Returns number

  • setUTCHours

    • setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number

      Sets the hours value in the Date object using Universal Coordinated Time (UTC).

      Parameters

      • hours: numberA numeric value equal to the hours value.
      • min?: numberA numeric value equal to the minutes value.
      • sec?: numberA numeric value equal to the seconds value.
      • ms?: numberA numeric value equal to the milliseconds value.

      Returns number

  • setDate

    • setDate(date: number): number

      Sets the numeric day-of-the-month value of the Date object using local time.

      Parameters

      • date: numberA numeric value equal to the day of the month.

      Returns number

  • setUTCDate

    • setUTCDate(date: number): number

      Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).

      Parameters

      • date: numberA numeric value equal to the day of the month.

      Returns number

  • setMonth

    • setMonth(month: number, date?: number): number

      Sets the month value in the Date object using local time.

      Parameters

      • month: numberA numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
      • date?: numberA numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.

      Returns number

  • setUTCMonth

    • setUTCMonth(month: number, date?: number): number

      Sets the month value in the Date object using Universal Coordinated Time (UTC).

      Parameters

      • month: numberA numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
      • date?: numberA numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.

      Returns number

  • setFullYear

    • setFullYear(year: number, month?: number, date?: number): number

      Sets the year of the Date object using local time.

      Parameters

      • year: numberA numeric value for the year.
      • month?: numberA zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.
      • date?: numberA numeric value equal for the day of the month.

      Returns number

  • setUTCFullYear

    • setUTCFullYear(year: number, month?: number, date?: number): number

      Sets the year value in the Date object using Universal Coordinated Time (UTC).

      Parameters

      • year: numberA numeric value equal to the year.
      • month?: numberA numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.
      • date?: numberA numeric value equal to the day of the month.

      Returns number

  • toUTCString

    • toUTCString(): string

      Returns a date converted to a string using Universal Coordinated Time (UTC).

      Returns string

  • toISOString

    • toISOString(): string

      Returns a date as a string value in ISO format.

      Returns string

  • [toPrimitive]

    • [toPrimitive](hint: literal default): string

      Converts a Date object to a string.

      Returns string

    • [toPrimitive](hint: literal string): string

      Converts a Date object to a string.

      Returns string

    • [toPrimitive](hint: literal number): number

      Converts a Date object to a number.

      Returns number

    • [toPrimitive](hint: string): string | number

      Converts a Date object to a string or number.

      Parameters

      • hint: stringThe strings "number", "string", or "default" to specify what primitive to return.

      Returns string | number

      A number if 'hint' was "number", a string if 'hint' was "string" or "default".

Properties

Also in this Section