
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2015 04:37 AM
I have a task where I put the date in the subject line. This request gets created every night a 9:30 pm EDT but for some reason the date that gets put into is not the date the request and tasks were created but the next days date. Why is it note pulling the correct date? Our system default time zone is US/Eastern
var gdt = new GlideDateTime();
var date = gdt.getDate();
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2015 06:48 PM
I found a different work around. Instead of using .getDate() in my code I changed it to getLocalDate(). This gets the date based on the submitters timezone. I used my servicenow local admin account as the submitter and made sure the timezone was Eastern.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2015 04:41 AM
do a split and you can separate out the date and time..
variablename.split(' ');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2015 04:50 AM
I think it is giving you UTC.
var time = new GlideDateTime();
gs.print(time);
var tz = Packages.java.util.TimeZone.getTimeZone("America/New_York");
time.setTZ(tz);
gs.print(time.getDisplayValue());
This will set it to the correct time zone. Now you just have to run your date function on that and you should be ok.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2015 04:51 AM
Hi Brian,
This is a time zone issue for sure. using this will resolve it
new GlideDateTime().getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2015 08:14 PM
Get display value did not resolve the issue. It is still showing the day after the created date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2015 10:18 PM
Hi Brian, are you looking something like the following:
((new GlideDateTime().getDisplayValue()).split(' ') [0])
Thanks,
Berny