Set Date and Time to Next Day at Specific TIme
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 12:39 PM
I'm attempting to set the date and time for a field on a catalog item. I'm calling it a "Need by Date". The requirement is to default the date and time 1 day out, and set the time to 7:00:00 that day. Can someone help configure this? I'm using a GlideDateTime (addDay(1)) and GlideTime (setValue) which is adding 7 hours to the current date/time.
Here's the script I'm using:
javascript:
var gdt = new GlideDateTime();
var gtime1 = new GlideTime();
gdt.addDays(1);
gtime1.setValue("07:00:00");
gdt.add(gtime1);
gdt.getDisplayValue();
Here is What's Happening:
If the current date and time were: 02-09-17 15:00:00
The catalog item form will load and display: 02-10-17 22:00:00
Any help is appreciated!
Thanks,
-Marques

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2017 10:26 AM
Thanks Marques-
This helps a lot
Matthew

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2017 10:29 AM
Try the follwing code in Background Script and see if you get the right answer.
var gdt = new GlideDateTime(); | |
gdt.addDays(1); | |
var newd = gdt.toString().slice(0,10) + " 07:00:00"; | |
task.start_date = newd; |
Please mark this response as correct or helpful if it assisted you with your question.