Why setDisplayValue in glide date time object adding 6 hrs?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 03:42 AM
var startdate = 2024-11-13
var gdtStartDate = new GlideDateTime();
gs.print(gdtStartDate);
gdtStartDate.setDisplayValue( startdate + ' 00:00:00');
Why it is printing date with 6 hrs.? as it is supposed to print with 2024-11-13 00:00:00?
2024-11-13 06:00:00
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 03:58 AM
Make your startdate var a string
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 04:04 AM
thats typo here but i did so in background script.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 04:10 AM
var empstartdate = "2024-11-13" ;
var gdtStartDate = new GlideDateTime();
gs.print(gdtStartDate);
gdtStartDate.setDisplayValue(empstartdate+ ' 00:00:00');
gs.print(gdtStartDate);
restult :
*** Script: 2024-11-05 12:09:57
*** Script: 2024-11-13 06:00:00
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 04:09 AM
Hello @Manikantahere
There is two small changes needed in the code:
- variable startdate should be a string therefore change it to "2024-11-13"
- Should be setValue instead of setDisplayValue
Here is the update code:
var startdate = "2024-11-13";
var gdtStartDate = new GlideDateTime();
gdtStartDate.setValue(startdate + ' 00:00:00');
gs.print(gdtStartDate);
output preview:
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar