- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2021 09:53 AM
I have the following code
<sn-time-ago timestamp="d.sys_created_on"></sn-time-ago>
to show how long ago a ticket was created in a sp widget. In testing, I noticed that for tickets that were just created, it shows 8h ago, and as of an hour later, it shows 9h ago. I checked the data in the actual ticket itself and it is correct. Is there something special that needs to be done here? Am I going to have to handle that logic myself?
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 03:07 PM
I was getting the display value of the field in the server script. Changed to gr.getValue('sys_created_on') and the proper time difference is shown.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2021 10:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2021 10:29 AM
It sounds like a timezone issue. Are you 8 hours behind UTC? Checking the directive definition at [instance].service-now.com/scripts/sn/common/datetime/directive.snTimeAgo.js, it looks like there are two scope parameters, 'timestamp' and 'local', and it looks like 'local' is a boolean, so maybe try:
<sn-time-ago timestamp="d.sys_created_on" local="true"></sn-time-ago>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2021 12:20 PM
Interesting, this did get me closer but still not quite right. it now shows 2h ago instead of 8h ago for new tickets.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2021 01:41 PM
Looks like the directive uses "new Date()" which is javascript's native date API, as opposed to SNOW's GlideDate/GlideDateTime. "new Date()" should be pulling your machine's time which might be different from your SNOW instance time? By 2 hours maybe?