- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2016 03:44 PM
Hi folks,
Just wondering if you could assist with the gs.now this time. the published date is a date type in KB_knowlege table (knowledge base), a client has raised the published date set to yesterday's date when she created a new KB. I was able to reproduce this in the early morning, and found a before business rule is setting the published date. Please see screenshot below
gs.now() in script background seems to output today's date and it does not output the time,
the question come to my head, is the gs.now() reflecting client's local time?
Any feedback is appreciated.
Kind regards,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 02:41 PM
Did you try it like this?
var gdt = new GlideDateTime();
gs.print(gdt.getDate());
That is displaying properly for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2016 07:07 PM
gs.now() returns GMT. You can use gs.nowDateTime() to see it in the user defined format and time zone.
GlideSystem Date and Time Functions - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 02:34 PM
Thanks Robert for your response. gs.nowDateTime() returns date and time, but the the published is a date that will not accept the time.
I tried to use gs.getDate() but it did not seem to return the date. Any advise?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 02:41 PM
Did you try it like this?
var gdt = new GlideDateTime();
gs.print(gdt.getDate());
That is displaying properly for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 03:44 AM
Hi George,
If you want the current date with time you can used the gs.nowDateTime() method.
gs.now() will return the current date using GMT, so its not with client local time.
But if you want the time in you local time you can try with method setDisplayValueInternal GlideDateTime - ServiceNow Wiki
Hope these details will help you, and if you go through the you can find more details on these.
BR,
/Suraj