Adding 1 hour to current date is not working as intended
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2018 05:53 PM
Hi,
I have a requirement to set the time from a UI page onto a scheduled job based on the current time
script :(to update the time on the job)
var gdt = new GlideDateTime(gs.nowDateTime());
var hours = 60*60*1;
gdt.addSeconds(hours);
and based on this I set my schedule job date:
rec.run_start = gdt.getValue();
Instead of updating the time on scheduled job to next hour )irrespective of AM or PM ) it only update the job date to AM
Can you please tell me what is the issue and how to fix this
Regards,
Manoj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2018 05:59 PM
you can do below
var gdt = new GlideDateTime();
var hours = 60*60*1;
gdt.addSeconds(hours);
rec.run_start = gdt.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2018 10:07 AM
HI Mike,
I think, if you look into my script it has the same code:
var hours = 60*60*1;
The major issue is
var hours = 60*60*1; will work if the current time is in AM and
var hours = 60*60*13; will work if the current time is in PM
I am looking to fix the script in such a way that it is dynamic in both AM and PM
Regards,
Manoj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2018 10:16 AM
Manoj,
If you look at my script difference is not hours. adding seconds has nothing to do with AM and PM.
var gdt = new GlideDateTime();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2018 10:50 AM
Hi Mike,
I tried the script you mentioned and run my UI page at 10:45:01 AM (current time) and the job updated to 12-11-2018 07:45:01 PM based on this script (9hours have been added)
var gdt = new GlideDateTime(gs.nowDateTime()); is working fine for the 60*60*1 during the AM.
Regards,
Manoj