Need help to understand date/time functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2016 11:47 PM
Hi All,
I got a doubt while working with date/time field manipulations. for example, if i need to trigger a notification in the workflow if the current date is less than a date/time field selected in the catalog time. From the wiki article, i got how to check for this condition. But, how can i acheive this without conflicting the time zones. (for example if i use gs.nowDateTime() it is giving date/time in user's time zone, if i use gs.nowNoTZ() it is giving date/time in GMT, so if a user from us time zone has raised a request then i think it may conflicted. so i was totally confused with these, could you please some one help me to understand this clearly(with example if possible).
Thanks and regards,
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 12:30 AM
The best practice to use Date time function is to write server side code(script include).
For more info GlideSystem Date and Time Functions - ServiceNow Wiki
Thanks
Akash Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 12:51 AM
You just make the custom date to display in the users time zone. So that it will be easy to compare.
var dt= new GlideDateTime();
dt.setvalue(current.due_date);
var actual_date=dt.getDisplayValue();
if(actual date < gs.nowDateTime()){
write your script here ;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 01:39 AM
Hi Behera,
Thanks for your reply. I am aware of these functions. My doubt is like when we should use gs.nowDateTime() and gs.nowNoTZ()?( how we can eliminate the time zone problem)?
Thanks and regards,
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 01:48 AM
HI Amaradi,
try using this script.
var actual_date_user_timezone = formatDate(actual_date, g_user_date_time_format);
this code will change the actual time to your user time zone.