ServiceNowでUTCとの時差を取得する
Version: Paris
ServiceNowのDate, Date/Time型
ServiceNowのDate/Time型ではDB内でUTC(GMT)のUNIXTIME(エポック秒)でミリ秒まで保持していて利用しているユーザーのTimezoneに従って計算して表示されているようです
[Date and Date/Time fields]
https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/time/reference/r_UseDateAndTimeFields.html
[Time configuration]
https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/core-configuration/concept/p_Time.html
とても便利な仕組みだと思いますがちょっと任意のTimezoneの値を取得したくなったので調べてみました
Packages.java.util.TimeZoneを使う
色々ググった結果この方法が見つかりました(関数にしています)
prt_tz_ofs("Asia/Tokyo");
prt_tz_ofs("US/Pacific");
prt_tz_ofs("Australia/Eucla");
function prt_tz_ofs(p_tz) {
var gdt = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone(p_tz);
gdt.setTZ(tz);
var tzoffs = gdt.getTZOffset() /1000/ 60/60;
gs.info(p_tz + " ha " + tzoffs + " hours!!");
}
Scripts - Backgroundで実行した結果が以下です
もうちょっと便利な方法があるかもですがやりたいことは出来ました
Author And Source
この問題について(ServiceNowでUTCとの時差を取得する), 我々は、より多くの情報をここで見つけました https://qiita.com/20_percent_cooler/items/0f11018e4cf15f79f9f2著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .