https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_reference/GlideDateTime/concept/c_GlideDateTimeAPI.html
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0594666
To create a GlideDateTime object with the current date and time, do not provide a parameter. Simply call the constructor of the GlideDateTime class and the value is initialized to the current date and time.
// Do this
var dgt = new GlideDateTime();
Do not use gs.nowDateTime() to set a GlideDateTime object. The nowDateTime() method returns the date time in local format and the local time zone. The GlideDateTime object uses the date time in the internal format and UTC time zone.
//Not this
var gdt = new GlideDateTime(gs.nowDateTime());
glide date time is default UTC, you can set timezone :
https://www.servicenow.com/community/in-other-news/demystifying-glidedatetime-and-timezones-also-convert-dates-to/ba-p/2472586
var gdt = new GlideDateTime();
gdt.setTimeZone('US/Eastern');
gs.info(gdt.getDisplayValue());
GlideDateTime - getDisplayValue()
Gets the date and time value in the current user's display format and time zone.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Object | Date and time in the user's format and time zone. Keep in mind when designing business rules or script includes that this method may return values in different formats for different users. |
No comments:
Post a Comment