Changing date format in Service Portal Catalog Item Variable from "dd/MM/yyyy" to "MM/dd/yyyy"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2023 05:11 PM
Hello. I have a catalog item that has a variable date field called Expected Date (expected_date) where it inputs a date with the default format of "DD/MM/YYYY".
I want to make it so that the default value and any other value inputted in this field is always in a "MM/DD/YYYY" format without the need to change the System Property of the date format in the instance.
Is there any way to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2023 09:25 PM
I have tried that already with a script include and client script with GlideAjax. It doesn't work for me unfortunately even after double-checking the code and all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2023 10:25 PM
Hi @Von Naval Could you please share what have you done so far and please share screenshots.
So I can help you to resolve your issue.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2023 11:17 PM
Hi Von ,
Please try below code, use getByFormat() method of GlideDate api.
var formatdate= day.getByFormat("MM-dd-yyyy");
Thank you,
Vallabh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2023 11:38 PM
the formats will change based on user's date format.
for your case you need to update the default system date format but it will be impact entire instance wherever date fields/variables are used.
I won't recommend that.
Inform the customer about the same.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 06:42 AM
Hi Ankur, I have a requirement to override user date format and set the system date format in a record producer variable. Any thoughts?
For instance, the systeam date format is DD/MMM/YYYY; a user has set the date preference to mm/dd/yyyy.
Now in the Record producer date variable the format should be DD/MMM/YYYY for all users irrespective of their preference.
Please advise