Not allowed in scoped apps, and what to use instead
These GlideDateTime and GlideSystem calls work in the global scope only. The helper writes the scoped version when you choose “A scoped app”.
| Global only | Works in every scope |
|---|---|
addDays(n) | addDaysLocalTime(n) or addDaysUTC(n) |
gs.dateDiff(a, b) | end.getNumericValue() - start.getNumericValue(), or GlideDateTime.subtract(start, end) |
gs.nowDateTime() | new GlideDateTime() |
setTimeZone(tz) | A global script include, called from the scoped app |
setNumericValue(ms) | new GlideDateTime('1970-01-01 00:00:00') then add(ms) |
Local time or UTC?
On most days they agree. When a daylight saving change falls between the two dates, addDaysLocalTime(1) keeps the clock time
(10:30 stays 10:30) while addDaysUTC(1) adds exactly 24 hours (10:30 becomes 09:30 or 11:30). For due dates people read,
local time is usually what they expect. Enter 2026-10-24 08:30:00 above with Europe/Stockholm and add one day to see it.
Date pattern letters
ServiceNow formats and parses dates with Java SimpleDateFormat patterns, in setDisplayValue(value, format), getByFormat() and the date format on the user record.
yyyy2026yy26MM10MMMOctMMMMOctoberdd21EEEWedEEEEWednesdayHH00-23hh01-12mmminutessssecondsaAM / PM'at'literal text