Global date and time field format

  • Release version: Washingtondc
  • Updated August 1, 2024
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Global Date and Time Field Format

    This guide outlines how ServiceNow administrators can configure global date and time formats using system properties. The properties involved includeglide.sys.dateformatfor date formatting andglide.sys.timeformatfor time formatting.

    Show full answer Show less

    Key Features

    • Date Format: Default is yyyy-MM-dd. Administrators can modify this by navigating to System Properties > System. Users can override this format with personal preferences.
    • Time Format: Default is HH:mm:ss. Similar modification options apply as with date formats. Users can also set personal preferences.
    • Validation: It is essential to validate any changes made using a Validate date and time script to prevent errors, particularly regarding time zones.
    • Format Abbreviations: Both date and time formats use specific abbreviations (e.g., MM for months, HH for hours) which should be followed to ensure accuracy.

    Key Outcomes

    By configuring the global date and time formats, administrators can ensure consistency across the ServiceNow platform. Proper setup minimizes the risk of invalid date errors and maintains clarity for all users interacting with date and time fields. This enables a more streamlined user experience and improves data integrity within the system.

    You define default date and time formats globally using system properties.

    Date format

    The glide.sys.date_format property defines the date format. An administrator can modify the property by navigating to System Properties > System. The default format is: yyyy-MM-dd.

    Note:
    A user can override the global date or time format with a personal preference.
    Modifying the glide.sys.date_format property changes the date or time format globally. When modifying the standard date format, also verify the format using a Validate date and time script. You can use the same pattern strings as the java.text.SimpleDateFormat class, with the following exception:
    • You cannot append the 'z' character to include the time zone when adding it to a script.
    • If the resulting time zone is not three characters, an Invalid Date appears error appears when you validate the script, because the Date/Time Validation Script (sys_script_validator) fails. This failure occurs even though the script debugger shows that the content of the value meets the requirement of 'g_user_date_time_format'.
    MM is months, while mm indicates minutes. The format string consists of the following abbreviations.
    Field Full form Short form
    Year yyyy (4 digits) yy (2 digits), y (2 or 4 digits)
    Month MMM (name or abbr.) MM (2 digits), M (1 or 2 digits)
    Day of Month dd (2 digits) d (1 or 2 digits)
    Note:
    It is recommended that you use a yyyy format-based date. For example, use MM-dd-yyyy, yyyy-MM-dd, or dd-MM-yyyy.
    • If your system date format is set to use the yy year format, the system considers dates 20 years later or 80 years earlier from the current date as a date in the past or future leading to an unexpected behavior.
    • For example, if you set the year as 51 for 2051, the system considers the year as 1951. Similarly, if you set the year as 37 for 1937, the system considers the year as 2037.

    Time format

    An administrator can modify the glide.sys.time_format property by navigating to System Properties > System. Modifying the property changes the date or time format globally. When modifying the standard time format, also verify the format using a Validate date and time script. You can use the same pattern strings as the java.text.SimpleDateFormat class, with the following exception: Appending 'z' to include the time zone is not supported.

    The format string consists of the following abbreviations.

    Field Full form Short form
    Hour (1-12) hh (2 digits) h (1 or 2 digits)
    Hour (0-23) HH (2 digits) H (1 or 2 digits)
    Minute mm (2 digits) m (1 or 2 digits)
    Second ss (2 digits) s (1 or 2 digits)

    Add the character a to the end of the time format string to indicate AM or PM. This option shows AM or PM whether you are using 12-hour time (hh) or 24-hour time (HH).

    The default format is: HH:mm:ss.

    Note:
    A user can override the global date or time format with a personal preference.