SugarCRM js or jquery get current user date format and write back to crm.

SugarCRM js or jquery get current user date format and write back to crm.

September 29, 2018 javascript jQuery PHP SugarCRM 0

for example get 'start_date_time_date_c_date' and add days after write added date to SugarCRM

function calculatePaymentDueDate()

{

var lsns_per_mnth = $("#lessons_per_month_c").val();

var sd = document.getElementById('start_date_time_date_c_date').value;

var s_date = sd.split(" ");

 

var aa= cal_date_format.split("%");

 

var divid=aa[1].substr(-1);

var firstw=aa[1].substring(0,1).toLowerCase();

var secw=aa[2].substring(0,1).toLowerCase();

var thirdw=aa[3].substring(0,1).toLowerCase();

 

//console.log(new Date(s_date[0]));

 

var dddate=s_date[0].split(divid);

 

var dfirst=dddate[0];

var dsec=dddate[1];

var dthird=dddate[2];

 

var dateforma1= cal_date_format.replace(/%/g, "");

var crmdate='';

switch(dateforma1)

{

 

case 'Y-m-d':

crmdate=dsec+'/'+dthird+'/'+dfirst;

break;

 

case 'm-d-Y':

crmdate=dfirst+'/'+dsec+'/'+dthird;

break;

 

case 'd-m-Y':

crmdate=dsec+'/'+dfirst+'/'+dthird;

break;

 

case 'Y/m/d':

crmdate=dthird+'/'+dfirst+'/'+dsec;

break;

 

case 'm/d/Y':

crmdate=dfirst+'/'+dsec+'/'+dthird;

break;

 

case'Y.m.d':

crmdate=dfirst+'/'+dsec+'/'+dthird;

break;

 

case 'm.d.Y':

crmdate=dfirst+'/'+dsec+'/'+dthird;

break;

 

case 'd.m.Y':

crmdate=dsec+'/'+dfirst+'/'+dthird;

break;

 

default:

crmdate=dsec+'/'+dfirst+'/'+dthird;

 

}

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *