@servicenow/sdk - v4.4.1
    Preparing search index...
    interface DateTimeFns {
        addTime: AddTime;
        dateDifference: DateDifference;
        dateToString: DateToString;
        day: Day;
        endOfMonth: EndOfMonth;
        hour: Hour;
        minute: Minute;
        month: Month;
        second: Second;
        stringToDate: StringToDate;
        subtractTime: SubtractTime;
        week: Week;
        year: Year;
    }
    Index

    Properties

    addTime: AddTime

    Adds days, hours, minutes, and/or seconds to the input Date/Time, Date, or Due Date.

    Date/Time, Date, or Due Date If the input is a Date or Due Date, the transform creates a full date/time value using time values of hour 0, minute 0, and second 0.

    Object specifying any of days, hours, minutes, seconds. Omitted units default to 0.

    Date/Time - Transformed Date/Time after adding the specified Duration

    addTime(new Date('2021-05-02 09:10:12'), { days: 2, hours: 3 }) // → '2021-05-04 12:10:12'
    

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    dateDifference: DateDifference

    Return a duration of time between the input date and the parameter date time.

    DateTime/DueDate/Date

    Date/Time, Due Date or Date to calculate difference between the given input.

    Duration- Returns the duration of time added to epoch time (1970-01-01) in Date/Time format, representing the difference between two input dates.

    dateDifference('2021-05-02 09:10:12', '2021-04-07 06:02:23') // → '1970-01-26 03:07:49'
    

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    dateToString: DateToString

    Converts a Date/Time, Date, or Due Date to a formatted string.

    Date/Time, Date, or Due Date - If the input is a Date or Due Date, the transform creates a full date/time value using time values of hour 0, minute 0, and second 0.

    Date/time or date format of the output String. Predefined format choice value. Use Custom for custom

    Required Valid date/time or date format represented as a String. Required only if Custom Format is selected as the Date Format.

    String - String formatted as specified in Output Date Format

    dateToString('1996-01-16 19:56:10', 'MM/dd/yy') // → '01/16/96'
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    Common Date Formats

    |--------------------|--------|----------------------------|

    Format Type Format Example
    Year y 1970, 1971, ... 2004, 2005
    Month MM 01, 02, ... 11, 12
    Month Name MMM Jan, Feb, ... Nov, Dec
    Day in Month dd 01, 02, ... 30, 31
    Day Name EEE Sun, Mon, ... Fri, Sat
    Hour (12-hour) h 1, 2, ... 11, 12
    Hour (24-hour) HH 00, 01, ... 22, 23
    Minute in Hour mm 00, 01, ... 58, 59
    Second in Minute ss 00, 01, ... 58, 59
    Escape Character ' 'at' h:mm a = at 1:30 PM
    (Single Quote)
    -------------------- -------- ----------------------------
    day: Day

    Returns the day of the month for a specific date and time.

    Date/Time value.

    Integer - returns day component of the specified input.

    day('2021-11-20 13:06:12') // → 20
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    endOfMonth: EndOfMonth

    Returns a date representing the last day of a month which falls a specified number of months before or after specified date.

    Base date.

    Number of months to be added to specified date.

    Date/Time - Returns a date representing the last day of a month which falls a specified number of months before or after specified date.

    endOfMonth('2021-05-15', 1) // → '2021-06-30 00:00:00'
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    hour: Hour

    Returns the hour component of a specific date and time.

    Date/Time value.

    Integer - Hour component of the specified input.

    hour('2021-11-20 13:06:12') // → 13
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    minute: Minute

    Returns the minute component of a specific date and time.

    Date/Time value.

    Integer - Minute component of the specified input.

    minute('2021-11-20 13:06:12') // → 6
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    month: Month

    Returns the month component of a specific date and time.

    Date/Time value.

    Integer - Month component of the specified input.

    month('2021-11-20 13:06:12') // → 11
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    second: Second

    Returns the seconds component of a specific date and time.

    Date/Time value.

    Integer - Seconds component of the specified input.

    second('2021-11-20 13:06:12') // → 12
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    stringToDate: StringToDate

    Converts the input String to a Date/Time.

    String formatted as specified in Input Date Format

    Date/time or date format of the input String. Predefined format choice value. Use Custom for custom

    Required Valid date/time or date format represented as a String. Required only if Custom Format is selected as the Date Format.

    Date/Time - If the date/time value for the Custom Format is incomplete, the transform creates a full date/time value using default dates and times. The transform defaults to the current year, the current month, day 1 of a month, hour 0, minute 0, and second 0.

    stringToDate('1995-11-20', 'yyyy-MM-dd') // → '1995-11-20 00:00:00'
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not String, the data is not transformed at runtime.

    Common Date Formats

    |--------------------|--------|----------------------------|

    Format Type Format Example
    Year y 1970, 1971, ... 2004, 2005
    Month MM 01, 02, ... 11, 12
    Month Name MMM Jan, Feb, ... Nov, Dec
    Day in Month dd 01, 02, ... 30, 31
    Day Name EEE Sun, Mon, ... Fri, Sat
    Hour (12-hour) h 1, 2, ... 11, 12
    Hour (24-hour) HH 00, 01, ... 22, 23
    Minute in Hour mm 00, 01, ... 58, 59
    Second in Minute ss 00, 01, ... 58, 59
    Escape Character ' 'at' h:mm a = at 1:30 PM
    (Single Quote)
    -------------------- -------- ----------------------------
    subtractTime: SubtractTime

    Subtracts days, hours, minutes, and/or seconds from the input Date/Time, Date, or Due Date.

    Date/Time, Date, or Due Date - If the date/time value for the Custom Format is incomplete, the transform creates a full date/time value using default dates and times.

    Object specifying any of days, hours, minutes, seconds. Omitted units default to 0.

    Date/Time - Transformed Date/Time after subtracting the specified Duration

    subtractTime(new Date('2021-05-04 12:10:12'), { days: 2, hours: 3 }) // → '2021-05-02 09:10:12'
    

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    week: Week

    Returns the week of the year that a specific date falls on.

    Date/Time value.

    Integer - Week of the year that a specific date falls on

    week('2021-04-07 12:01:12') // → 15
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.

    year: Year

    Returns the year component of a specific date and time.

    Date/Time value.

    Integer - Year component of the specified input

    year('2021-11-20 13:06:12') // → 2021
    

    Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone.

    If input data type is not Date/Time, Date, or Due Date, the data is not transformed at runtime.