Date Format

John H1
Tera Guru

I'm having a problem when I enter a date, I have a script to generate a second date. The script does its job but the date format is wrong and needs to be modified. It needs to be 07/05/2024 but I'm getting 2024-07-05.

Here is the script I'm running

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading) {
        return;
    }
    if(newValue === '')
    {
        g_form.clearValue('certificate_expiration_date');
    }
    var ga = new GlideAjax('myDateUtil');
    ga.addParam('sysparm_name','getEndDate');
    ga.addParam('sys_parm_issue_dt',newValue);
    ga.addParam('sys_parm_how_many_months',27);
    ga.getXML(cb);  

    // the callback function for returning the result from the server-side code
    function cb(response) {  
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if(answer)
        g_form.setValue('certificate_expiration_date',answer);
    }
           
    //Type appropriate comment here, and begin script below

}
2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

Hi John,

Are you setting the value to a string field ? if it is a date type it should handle it on its own.

 

-Anurag

John H1
Tera Guru

'm and using Date format.