How to set Date Variable in MM/dd/YYYY format using onChange Client Script

Shraddha Kadam
Giga Sage

Hello All,

On the RITM form I want to update the date variable. When I update the date variable the date is in the 'yyyy/dd/MM' format. I want the date variable is in the 'MM/dd/yyyy' format using onChange client script.

Anyone please help me.

I will appreciate the response.

Thank you.

1 ACCEPTED SOLUTION

@Shraddha Kadam 

GlideAjax Example

Use this script include and send the value which is in yyyy/dd/MM format

var MyConversion = Class.create();
MyConversion.prototype = {
	initialize: function() {
	},

	convertDateFormat: function(){

		var incomingDate = this.getParameter('sysparm_format') + ' 00:00:00';
		var format = 'yyyy/dd/MM HH:mm:ss';
		var gdt = new GlideDateTime();
		gdt.setDisplayValue(incomingDate,format);
		var gd = new GlideDate(); 
		gd.setValue(gdt.getDate());
		return gd.getByFormat("MM/dd/yyyy");

	},

	type: 'MyConversion'
};

Regards
Ankur

View solution in original post

15 REPLIES 15

Zach Koch
Giga Sage

This link may help you

https://community.servicenow.com/community?id=community_question&sys_id=1e028662db90e010f21f5583ca96...

If this solved your issue, please mark this correct and helpful, thank you!

Ankur Bawiskar
Tera Patron

@Shraddha Kadam 

Why do you wish to change the format?

The format which is shown is as per logged in user's date format

Regards
Ankur