Changing date format in Service Portal Catalog Item Variable from "dd/MM/yyyy" to "MM/dd/yyyy"

Von Naval
Tera Contributor

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".

VonAubreyNava_0-1676941791938.png

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?

10 REPLIES 10

Kathiresan S
Tera Contributor

Hi, 

You can use the below format :

var date= new GlideDate();
gs.info(date.getByFormat('MM-dd-YYYY'));
Please mark this as correct and helpful if it resolves the query or leads you in the right direction.

 

Thanks,
Kathiresan S

 

Please mark this as correct and helpful if it resolves the query or leads you in the right direction.



Thanks,
Kathiresan S

Hey Kat. Where should I put this specific code?

In the catalog client script 

Please mark this as correct and helpful if it resolves the query or leads you in the right direction.



Thanks,
Kathiresan S

Sonu Parab
Mega Sage
Mega Sage

Hi @Von Naval , Have a look at this post. Date Format Change to "dd-mm-yyyy" for catalog item variable 
Please go through the above script and change according to the your requirement.

Let us know if you are facing any issue

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

Thank you