What It Does

The getDisplayValue() method converts a GlideDateTime object to a user-readable string representation. It applies the current user's timezone offset and formats the result according to their configured date/time display preferences.

Internally, ServiceNow performs three transformations: first, it converts the stored UTC time to the user's timezone using their profile settings or the system default. Second, it applies the user's date format preference (MM/dd/yyyy, dd/MM/yyyy, etc.) and time format preference (12-hour vs 24-hour). Finally, it localizes any text elements like "AM/PM" based on the user's language settings.

The method returns a formatted string that matches exactly what users see in the platform UI for date/time fields. If the GlideDateTime object is invalid or null, it returns an empty string. The formatting includes both date and time components unless the stored value represents a date-only field.

Edge cases include handling of daylight saving time transitions and dates before 1970 or after 2038 on some systems. The method automatically accounts for DST changes, so a time stored during standard time will display correctly when viewed during daylight time. For dates outside the typical Unix timestamp range, behavior depends on the underlying Java implementation.

This method differs from getValue() which returns the raw stored value in YYYY-MM-dd HH:mm:ss format, and from getDisplayValueInternal() which formats using system defaults rather than user preferences.

When to Use This

Use getDisplayValue() when building user-facing output like email notifications, UI messages, reports, or any content that users will read. This ensures dates appear in the format users expect based on their personal preferences and location.

Avoid this method when you need consistent formatting for system integrations, data exports for processing by other systems, or database operations. In those cases, use getValue() for the raw stored format, or format the date yourself using getDisplayValue() with a specific format string. Common mistakes include using getDisplayValue() in REST API responses where the consumer expects consistent ISO format.

Return Value

Returns a string containing the formatted date and time. The exact format depends on the user's preferences, but typically follows patterns like "12/31/2023 11:59 PM" for US users or "31/12/2023 23:59" for users with European formatting preferences. The string includes both date and time components separated by a space.

When the GlideDateTime object is invalid, uninitialized, or null, the method returns an empty string (""). This makes it safe to use in string concatenation without explicit null checks, though you should validate the result if an empty date/time would break your business logic.

Free Newsletter

Enjoying this? Get one deep-dive per week.

Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.

No spam · Unsubscribe anytime

Platform Behavior & Side Effects

  • No database queries or writes are performed — this is purely a formatting operation on data already in memory
  • Does not trigger Business Rules, ACLs, or any other server-side logic — it's a read-only operation
  • Performance is fast and results are not cached — each call performs the timezone conversion and formatting
  • Behavior is identical across all server-side contexts (Business Rules, Script Includes, Scheduled Jobs, etc.)
  • Uses the current user's profile settings, which may differ from the timezone of the ServiceNow instance
  • In scheduled jobs or system contexts where there's no current user, falls back to system default formatting
  • No notifications or audit entries are generated — this is a formatting utility with no business impact