How to change Date Format from YYYY-MM-DD to DD/MM/YYYY on Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2020 09:29 AM
So, I'm new to ServiceNow and I have this Date Type Field which I am using on a form on Service Portal.
- So when the end user selects the date on Portal it shows selected date in format DD/MM/YYYY.
- But when the end user submits the request, this format is changed to YYYY-MM-DD,
- This is because this format (YYYY-MM-DD) is selected in the system properties, which I can not change , because this will make changes globally, which is not desirable.
So, after the submission of the request too I want the field to accept the date in the format DD/MM/YYYY only.
This I want on the catalog item form on Portal.
How can I do this?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2020 10:42 AM
You can write catalog client script to set the date format on Submit
var MyDate = g_form.getValue('your variable name') ;
var gdt = new GlideDateTime(myDate);
gdt.setDisplayValue("myDate","dd-MM-yyyy HH:mm:ss");//uses current user session time zone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2020 11:52 AM
Hi,
Generally when a date is selected and stored in backend it will be stored in the system format which in your case is YYYY-MM-DD.
If you want to show it in a different format like in SP, then while fetching the date, you can use getByFormat function of GlideDate API. This will help you to get the format in the way you want instead of storing the date in different format.
Mark the comment as a correct answer and also helpful if this has helped to solve the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2020 12:07 PM
Hi Alfiya,
If this is only about taking input from user DD/MM/YYYY on portal and not about how you are storing it.
I would suggest you to create a custom data field widget and add it to catalog a UI macro widget and hide the actual data field widget.
Further you can write script to copy from user friendly date field to actual date field via g_form API.
For starters, refer below
https://www.esmalliance.com/2019/01/18/customisation-of-the-service-portals-date-and-time-picker/
How to embed widget in catalog item
https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/build/service-portal/task/ui-macro-widget.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2020 12:14 AM
I want to store the value in DD/MM/YYYY Format itself.