GlideDateTime
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 06:29 PM
<p> Can anyone please give Brief about GlideDateTime () and GlideDate() API's. with some Real time Examples.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 06:34 PM
GlideDateTime
The GlideDateTime API handles date and time values. It's more precise than GlideDate because it includes the time component.
Example:
var now = new GlideDateTime(); // Creates a GlideDateTime object with the current date and time.
gs.info('Current Date and Time: ' + now.getDisplayValue()); // Outputs the current date and time in the user's preferred format.
gs.info('Current Date and Time in UTC: ' + now.getUTCDatetime()); // Outputs the current date and time in UTC format.
GlideDate:
The GlideDate API specifically deals with dates without the time component. It's simpler than GlideDateTime if you only need the date.
Example:
var date1 = new GlideDate('2024-03-15');
var date2 = new GlideDate('2024-03-20');
if (date1.before(date2)) {
gs.info('date1 is before date2');
} else if (date1.after(date2)) {
gs.info('date1 is after date2');
} else {
gs.info('date1 and date2 are the same');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 06:49 PM
Refer the below link.
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 06:51 PM
you can easily find answer to this in docs and blogs etc.
Did you check that before posting question here?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader