Global date and time field format
Summarize
Summary of Global date and time field format
ServiceNow allows administrators to set default global date and time formats via system properties. These settings determine how date and time fields are displayed across the platform. Users can also override these defaults with personal preferences. Proper configuration ensures consistent and accurate date/time representation in your instance.
Show less
Key Features
- Date Format Configuration: The
glide.sys.dateformatproperty controls the global date format and is configurable under System Properties > System. The default format isyyyy-MM-dd. - Time Format Configuration: The
glide.sys.timeformatproperty controls the global time format and is also configurable under System Properties > System. The default format isHH:mm:ss. - Format Patterns: Both date and time formats use pattern strings similar to Java's
java.text.SimpleDateFormatclass, with the exception that appending the 'z' character for time zones is not supported in scripts due to validation errors. - Date Format Details: Use four-digit years (
yyyy) to avoid ambiguous date interpretations. The format supports months (MMfor two-digit months,MMMfor names), days (dd), and years (yyyy,yy). Avoid two-digit years to prevent unexpected past/future date calculations. - Time Format Details: Supports both 12-hour and 24-hour formats using
hh/horHH/H. Minutes and seconds usemm/mandss/s, respectively. Addingaappends AM/PM indicators even for 24-hour formats. - Validation: After modifying date or time formats, validate the changes using the "Validate date and time" script to ensure correctness and prevent errors.
- User Personalization: Individual users can personalize date and time formats to suit their preferences, overriding global settings for their sessions.
Practical Considerations for ServiceNow Customers
- Always use four-digit year formats (
yyyy) to avoid date misinterpretation issues related to two-digit years. - Validate format changes immediately to prevent invalid date/time errors in scripts and data entry.
- Be cautious about time zone formatting in scripts as 'z' is unsupported and may cause validation failures.
- Communicate global format changes with your users since personal preferences can override these settings.
- Configure formats centrally to ensure consistency across modules, reports, and integrations relying on date/time fields.
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.