- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 11:14 PM
Hi Team,
We have integration with third party tool, where I have to Send Time Range From- to in body.
In from time I have to send Current Date Time in ISO ISO8601 format: yyyy-MM-dd'T'HH:mm:ss'Z then
I have subtract 10 minutes into current date time and have to pass in "to"
How can we achieve it?
Please Help me here
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 11:19 PM
Hi,
So you want to subtract 10mins and then convert to ISO?
if yes then do this
var gdt = new GlideDateTime('your date time');
gdt.addSeconds(-600); // 10 mins is 600 seconds
var dt = gdt.getValue().split(' ');
var f = dt[0].split('-');
var t = dt[1].split(':');
var event = new Date(f[0], f[1]-1, f[2], t[0], t[1], t[2]);
var isoDate = event.toISOString();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 11:19 PM
Hi,
So you want to subtract 10mins and then convert to ISO?
if yes then do this
var gdt = new GlideDateTime('your date time');
gdt.addSeconds(-600); // 10 mins is 600 seconds
var dt = gdt.getValue().split(' ');
var f = dt[0].split('-');
var t = dt[1].split(':');
var event = new Date(f[0], f[1]-1, f[2], t[0], t[1], t[2]);
var isoDate = event.toISOString();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 11:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 12:07 AM
Hi,
you want to send date/time which is subtracted with 10mins ? that is what you mentioned
you have now time i.e. End time
you can subtract 10mins from it and it will be From time
I already shared script for conversion so convert both and send
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 02:30 AM