Convert string in datetime "dd/MM/yyyy"

Hi, how can i convert this string “2015/10/28” (from JSON “DV_EINDT_ODA”:“2015/10/28”)
into a date dd/MM/yyyy
I’ll try in html this…{{callU.DV_EINDT_ODA | date :“dd/MM/yyyy”}}
but the result is this
2015/10/28
Any idea? Thanks

Hi,

You can try this approach

thanks…but if you can help me in again… i’ll try
var dataHold = [];
dataHold = newObject.DV_EINDT_ODA.replace(null,"").replace("?","");
dataHold = dataHold.split("/");
var dataCorrect = dataHold[2] + “/” + dataHold[1] + “/” + dataHold[0];
console.log("dataCorrect "+ dataCorrect);

but in the json some DV_EINDT_ODA (it’s the data name) are null or “?” and i’ll get an error
TypeError: Cannot call method ‘replace’ of null
any idea??

What do you want to achieve generally?

is a json from an http get
for(var i=0;i<response.queueElements.length;i++){
//DV_EINDT_ODA è la data
var newObject = {
//forse togliere elementi e columns
//elementi:response.queueElements[i],
caseFolderId:response.queueElements[i].caseFolderId.replace("{","").replace("}",""),
caseTaskId:response.queueElements[i].caseTaskId.replace("{","").replace("}",""),
stepName:response.queueElements[i].stepName,
columns:response.queueElements[i].columns,
DV_Caseidentifier_for_eni_OdA: response.queueElements[i].columns.DV_Caseidentifier_for_eni_OdA,
DV_EBELP_ODA: response.queueElements[i].columns.DV_EBELP_ODA,
DV_EINDT_ODA: response.queueElements[i].columns.DV_EINDT_ODA,
DV_MATNR_TXZ01_POS_ODA: response.queueElements[i].columns.DV_MATNR_TXZ01_POS_ODA,
DV_NAMECL_POS_ODA: response.queueElements[i].columns.DV_NAMECL_POS_ODA,
DV_NETPR_WAERS_POS_ODA: response.queueElements[i].columns.DV_NETPR_WAERS_POS_ODA,
DV_PEINH_POS: response.queueElements[i].columns.DV_PEINH_POS,
DV_MENGE_MEINS_POS_ODA: response.queueElements[i].columns.DV_MENGE_MEINS_POS_ODA
};

now in this for i’ll try this

            console.log("data "+ newObject.DV_EINDT_ODA);


            var dataHold = []; 
          
              if((newObject.DV_EINDT_ODA !== null) && (newObject.DV_EINDT_ODA !== "?")){
                dataHold = newObject.DV_EINDT_ODA;              
                dataHold = dataHold.split("/");
                var dataCorrect = dataHold[2] + "/" + dataHold[1] + "/" + dataHold[0];
                console.log("dataCorrect "+ dataCorrect);
              }else{
               console.log("sto cazzo");
              }

because i need to show data in the right format after, get from db

If you want to convert the date in array in order to have each value separately please take a look the codepen again

1 Like