How to add hours to a Date/Time value in widget client_script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 10:26 PM
Hi All,
How to add current date + 72 hr in client script. in widgets.
reagrds,
siva
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 11:19 PM
Hi
You might want to use getDisplayValue() to get in the user's time zone
var gdt = new GlideDateTime(gs.beginningOfNextWeek());
var hours = 60*60*72;
gdt.addSeconds(hours);
gs.print(gdt.getDisplayValue());
And this is how you run this client script on widget:
https://community.servicenow.com/community?id=community_question&sys_id=a8161c08dbb59c504819fb2439961982
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 11:51 PM
Hi Siva,
you can perform the same operation on server side and pass that value to Client-side.
var gdt = new GlideDateTime();
console.log('current date'+gdt);
var hours = 259200;//72 hours
gdt.addSeconds(hours);
console.log('new date:'+gdt.getDisplayValue());