I want to use gs.beginningOfToday() for a specific timezone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 06:45 PM
I want to use gs.beginningOfToday() for a specific timezone.
I want to use javascript:gs.beginningOfToday()@javascript:gs.endOfToday() in a script to get the records created today.
As far as I know, the timezone for javascript:gs.beginningOfToday()@javascript:gs.endOfToday() depends on the timezoneof the user running that script.
If I want to get it in a specific timezone regardless of the user's timezone, what do I need to do?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 01:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 01:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 02:30 AM
Thank you for telling me the case of ScriptInclude.
I want to use the scriptedAPI in a scoped application.
How do I do this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 03:23 AM
Call the Script Include from Scripted API.
I've written an article (in Japanese) on Scripted REST API. There is an example of calling Script Include from Scripted REST API.
The example is in Global but can be used in scoped application too. Make Scripted REST API and Script Include in the same scope.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 07:49 PM
Script Include:
var DateTimeUtil10 = Class.create();
DateTimeUtil10.prototype = {
initialize: function() {},
getBeginningOfToday: function(timezone) {
var today = gs.beginningOfToday();
var gdt = new GlideDateTime(today);
var tz = Packages.java.util.TimeZone.getTimeZone(timezone);
gdt.setTZ(tz);
var tzDiff = gdt.getTZOffset() / 1000 / 60 / 60;
return gdt.getDisplayValue();
},
getEndOfToday: function(timezone) {
var today = gs.beginningOfToday();
var gdt = new GlideDateTime(today);
var tz = Packages.java.util.TimeZone.getTimeZone(timezone);
gdt.setTZ(tz);
var tzDiff = gdt.getTZOffset() / 1000 / 60 / 60;
return gdt.getDisplayValue();
},
type: 'DateTimeUtil10'
};
variable 1:Default value:
javascript: new DateTimeUtil10().getBeginningOfToday('Asia/Tokyo');
variable 2:Default value:
javascript: new DateTimeUtil10().getBeginningOfToday('America/Los_Angeles');
Execution result: