Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
320
Date Format as mm/dd/year
posted

i am holding selected date value at client side in varibale.

 i want that value  should be as mm/dd/year. 

Please send s code for that .

 

  • 24497
    posted

    Hi,

    If you want to store date as string in a global variable, then you need to write conversion/filters for get/setValue member functions. Example:

    var myValueOfWebDC = null;

    function checkVal()
    {
     
    var dc = igdrp_getComboById('WebDateChooser1');
     
    //or
     
    //var dc = ig$('WebDateChooser1');
     
    if(!dc)
      
    return;
      //example to convert Date value as string
     
    var val = dc.getValue();
     
    if(val)
         myValueOfWebDC =
    '' + (val.getMonth() + 1) + '/' + val.getDate() + '/' + val.getFullYear();
     
    else
       
    myValueOfWebDC = null;

      //example to set Date value from your string
     
    var date = null;
     
    if(myValueOfWebDC)
      {
      
    var fields = myValueOfWebDC.split('/');
       date =
    new Date();
       date.setFullYear(parseInt(fields[2]));
       date.setMonth(parseInt(fields[0]) - 1);
       date.setDate(parseInt(fields[1]));
       date.setHours(0);
       date.setMinutes(0);
       date.setSeconds(0);
       date.setMilliseconds(0);
      }
      alert(
    "value in WebDC=" + myValueOfWebDC + "\nactual date:" + date);
      
    //dc.setValue(date);
    }