- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 11:02 AM
Hi,
I am trying to use the addSeconds() method in the following way:
var x = new GlideDateTime(current.due_date);
gs.log("x: " + x.getValue());
var y = new GlideDateTime(x);
gs.log("y: " + y.getValue());
var z = y.addSeconds(3600);
gs.log("z: " + z.getValue());
The values for x and y prints out fine. The value for z prints as 'undefined'. Please let me know if there is something wrong in it.
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 11:11 AM
Hi Dp,
Try this and check below. the method addSeconds doesn't return anything so it is giving undefined
var x = new GlideDateTime(current.due_date);
gs.log("x: " + x.getValue());
var y = new GlideDateTime(x);
gs.log("y: " + y.getValue());
y.addSeconds(3600);
gs.log("z: " + y.getValue());
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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
‎08-07-2018 11:10 AM
Please check if this helps,
var x = new GlideDateTime(current.due_date);
gs.log("x: " + x.getValue());
var y = new GlideDateTime(x.getValue());
gs.log("y: " + y.getValue());
y.addSeconds(3600);
gs.log('new time' + y.getValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 11:17 AM
Thanks Shishir. I overlooked the aspect that addSeconds did not return any value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 11:11 AM
Hi Dp,
Try this and check below. the method addSeconds doesn't return anything so it is giving undefined
var x = new GlideDateTime(current.due_date);
gs.log("x: " + x.getValue());
var y = new GlideDateTime(x);
gs.log("y: " + y.getValue());
y.addSeconds(3600);
gs.log("z: " + y.getValue());
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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
‎08-07-2018 11:18 AM
Thanks Ankur! I overlooked the fact that addSeconds() did not return any value.