- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2014 04:28 PM
Any javascript gurus out there that can provide a script that would set the default date in a "date" field for the prior day?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2014 09:16 AM
If you want to take the time zone into consideration, set the default value to:
For a Date field:
javascript:var gdt = new GlideDate();gdt.addDays(-1);gdt.getDisplayValue();
For a DateTime field:
javascript:var gdt = new GlideDateTime();gdt.addDays(-1);gdt.getDisplayValue();
The "getDisplayValue()" is the trick if you want to use the current user's time zone. Otherwise you will get the date in GMT, which could be an issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2014 12:29 PM
I have marked this discussion as a question. Feel free to mark the appropriate responses as correct or helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2014 12:31 PM
Thanks Bianca!