Global date and time field format
Summarize
Summary of Global date and time field format
ServiceNow administrators can define default global date and time formats using system properties. These global settings influence how dates and times appear across the platform, but individual users can override them with personal preferences. Proper configuration ensures consistent and accurate date/time handling throughout your instance.
Show less
Key Features
- Date Format: Controlled by the
glide.sys.dateformatproperty accessible via System Properties > System. The default isyyyy-mm-dd. Administrators can modify this format using Java SimpleDateFormat patterns, except the 'z' character for time zones is not supported in scripts. - Time Format: Controlled by the
glide.sys.timeformatproperty, also found in System Properties > System. The default time format isHH:mm:ss. It supports Java SimpleDateFormat patterns without 'z' for time zones. The character 'a' can be appended to indicate AM/PM in both 12-hour and 24-hour formats. - Validation: When changing either date or time formats globally, administrators should validate the format using the Validate date and time script to prevent errors.
- Year Format Recommendation: Use a 4-digit year format (
yyyy) to avoid issues with date interpretation, especially with years close to the current date, which may otherwise be misinterpreted.
Key Outcomes
- Consistent date and time presentation across your ServiceNow instance according to your organization’s standards.
- Prevention of date-related errors by adhering to recommended formatting and validating changes.
- Flexibility for end-users to personalize date and time formats to their preferences without impacting global settings.
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 . The default format is: yyyy-mm-dd.
- 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'.
| 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) |
- 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 . 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.