v5.20192.624
|

DateTime Class

Provides date and time utilities.

Hierarchy

  • DateTime

Methods

Static addDays

  • addDays(value: Date, days: number): Date
  • Gets a new Date that adds the specified number of days to a given Date.

    Parameters

    • value: Date

      Original date.

    • days: number

      Number of days to add to the given date.

    Returns Date

Static addHours

  • addHours(value: Date, hours: number): Date
  • Gets a new Date that adds the specified number of hours to a given Date.

    Parameters

    • value: Date

      Original date.

    • hours: number

      Number of hours to add to the given date.

    Returns Date

Static addMinutes

  • addMinutes(value: Date, minutes: number): Date
  • Gets a new Date that adds the specified number of minutes to a given Date.

    Parameters

    • value: Date

      Original date.

    • minutes: number

      Number of minutes to add to the given date.

    Returns Date

Static addMonths

  • addMonths(value: Date, months: number): Date
  • Gets a new Date that adds the specified number of months to a given Date.

    Parameters

    • value: Date

      Original date.

    • months: number

      Number of months to add to the given date.

    Returns Date

Static addSeconds

  • addSeconds(value: Date, seconds: number): Date
  • Gets a new Date that adds the specified number of seconds to a given Date.

    Parameters

    • value: Date

      Original date.

    • seconds: number

      Number of seconds to add to the given date.

    Returns Date

Static addYears

  • addYears(value: Date, years: number): Date
  • Gets a new Date that adds the specified number of years to a given Date.

    Parameters

    • value: Date

      Original date.

    • years: number

      Number of years to add to the given date.

    Returns Date

Static clone

  • clone(date: Date): Date
  • Creates a copy of a given Date object.

    Parameters

    • date: Date

      Date object to copy.

    Returns Date

Static equals

  • equals(d1: Date, d2: Date): boolean
  • Returns true if two Date objects refer to the same date and time.

    Parameters

    • d1: Date

      First date.

    • d2: Date

      Second date.

    Returns boolean

Static fromDateTime

  • fromDateTime(date: Date, time: Date): Date
  • Gets a Date object with the date and time set on two Date objects.

    Parameters

    • date: Date

      Date object that contains the date (day/month/year).

    • time: Date

      Date object that contains the time (hour:minute:second).

    Returns Date

Static fromFiscal

  • fromFiscal(date: Date, govt: boolean): Date
  • Converts a fiscal year date to a calendar date using the current culture.

    Parameters

    • date: Date

      Fiscal year date.

    • govt: boolean

      Whether to use the government or corporate fiscal year.

    Returns Date

Static newDate

  • newDate(year?: number, month?: number, day?: number, hour?: number, min?: number, sec?: number, ms?: number): Date
  • Gets a new Date object instance.

    Parameters

    • Optional year: number

      Integer value representing the year, defaults to current year.

    • Optional month: number

      Integer value representing the month (0-11), defaults to current month.

    • Optional day: number

      Integer value representing the day (1-31), defaults to current day.

    • Optional hour: number

      Integer value representing the hour, defaults to zero.

    • Optional min: number

      Integer value representing the minute, defaults to zero.

    • Optional sec: number

      Integer value representing the second, defaults to zero.

    • Optional ms: number

      Integer value representing the millisecond, defaults to zero.

    Returns Date

Static sameDate

  • sameDate(d1: Date, d2: Date): boolean
  • Returns true if two Date objects refer to the same date (ignoring time).

    Parameters

    • d1: Date

      First date.

    • d2: Date

      Second date.

    Returns boolean

Static sameTime

  • sameTime(d1: Date, d2: Date): boolean
  • Returns true if two Date objects refer to the same time (ignoring date).

    Parameters

    • d1: Date

      First date.

    • d2: Date

      Second date.

    Returns boolean

Static toFiscal

  • toFiscal(date: Date, govt: boolean): Date
  • Converts a calendar date to a fiscal date using the current culture.

    Parameters

    • date: Date

      Calendar date.

    • govt: boolean

      Whether to use the government or corporate fiscal year.

    Returns Date