ITSM

ayushigupta9
Tera Contributor

I have one date time field which is in format "01/27/2024 15:40:20" and i want it to show like "2024/01/27 15:40:20"

How to achieve this

 

Screenshot 2024-01-27 at 3.41.35 PM.png

Thanks in advance.

7 REPLIES 7

Danish Bhairag2
Tera Sage
Tera Sage

Hi @ayushigupta9 ,

 

U can try below code

 

var date= new GlideDate();//replace new GlideDate() with the incoming date

var date2 = date.getByFormat('yyyy/MM/dd');//now use the date2 to set the field value

 

Reference: https://www.servicenow.com/community/service-management-forum/how-to-modify-date-format-from-mm-dd-y...

 

Thanks,

Danish

 

Hi 

What do you mean by incoming date?

 

SarthakShri21
Tera Contributor

Hello @ayushigupta9 

Kindly check the logic applied in this solution and modify it as per your requirement

https://www.servicenow.com/community/service-management-forum/how-to-modify-date-format-from-mm-dd-y...

 

Thanks,

Sarthak

 

Mark my answer Helpful & Accepted if I have answered your question