how to convert date format to dd-mmm-yyyy in virtual agent.

kamer
Kilo Expert

Hi Team,

I have a requirement to display date into DD-MMM-YYYY format in email notification from virtual agent.

By default it is giving YYYY-MM-DD.

find_real_file.png

1 ACCEPTED SOLUTION

Imam Pasha1
Giga Guru

Hi Kamer,

I tried this code and working fine for as per your requirement what i understood.Please find the below code snippet

 

var startDate = vaInputs.start_date;  // start_date is input control name
var df = 'yyyy-MM-dd';
var gdt = new GlideDateTime(startDate);
gdt.setDisplayValue(startDate.df);
var localedt =gdt.getLocalDate();
var getStart= localedt.getByFormat('dd-MMM-yyyy');

 

 

output:

input from user:2020-03-30

output:30-Mar-2020

 

Hope this is helpful and please mark if you find the appropriate solution.

View solution in original post

7 REPLIES 7

Saurabh singh4
Kilo Guru

Hi Kamer

Here is the script, Please try this in yours

 

 

 var gd = new GlideDate();

//lets say the date is

  gd.setValue('2020-01-01');

 

  return{

 

  s.setStringParameter('u_actual_date', gd.getByFormat("MM/dd/yyyy")); //value of actual date

 

  }

  Please mark my answer correct and helpful, If this helps you in any waty thanks in advance

Saurabh

 

  

 

 

 

Imam Pasha1
Giga Guru

Hi Kamer,

I tried this code and working fine for as per your requirement what i understood.Please find the below code snippet

 

var startDate = vaInputs.start_date;  // start_date is input control name
var df = 'yyyy-MM-dd';
var gdt = new GlideDateTime(startDate);
gdt.setDisplayValue(startDate.df);
var localedt =gdt.getLocalDate();
var getStart= localedt.getByFormat('dd-MMM-yyyy');

 

 

output:

input from user:2020-03-30

output:30-Mar-2020

 

Hope this is helpful and please mark if you find the appropriate solution.

Hi Imam ,

Thank You.Its working now