How to get only the time from GlideDateTime
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 01:21 AM
I want to get only the time from GlideDateTime, but it does not work.
In getTime(), I get not only the time but also the date 1970-01-01.
I want to do a comparison with the GlideTime time, but thanks to this it does not work.
Is there any way to solve this problem?
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 01:28 AM
Hi,
string manipulation
var gdt = new GlideDateTime();
var onlyTime = gdt.toString().split(' ')[1];
gs.info("Only time ->" + onlyTime);
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2024 06:40 AM
The GlideDateTime method getUserFormattedLocalTime() returns only time, but not as GlideTime object
var gdt = new GlideDateTime();
gs.info(gdt.getDisplayValue());
gs.info(gdt.getUserFormattedLocalTime());
Output:
29-05-2024 14:37:23
14:37:23