GlideDateTime ServiceNow

GlideDateTime

The scoped GlideDateTime class provides methods for performing operations on GlideDateTime objects, such as instantiating GlideDateTime objects or working with glide_date_time fields.
Use the GlideDateTime methods to perform date-time operations, such as instantiating a GlideDateTime object, performing date-time calculations, formatting a date-time, or converting between date-time formats. See the GlideDateTime API reference for a complete list of methods.
ServiceNow provides no default logic for managing dates in applications. The NeedIt application, for example, has a When needed field. There is no default logic preventing a user from setting the When needed date to a date in the past.
A user setting the When needed date to 2007.
If you write applications that use dates, you may need to script logic for the date fields. Examples include:
  • Prevent users from selecting dates in the past
  • Do not allow start dates to be after end dates
  • Do not allow new requests to be submitted for today
When working with the GlideDateTime methods, pay attention to the date format and time zones. Some methods use GMT/UTC and some use local time zones. Some methods use the date in milliseconds and some do not.
NOTE: There are some useful methods for managing dates in the GlideSystem API also. For example, gs.daysAgo().