convert to ISO format

 "16-03-2020 07:30PM"; ISO format should be mm-dd-yyyy h:m PM
   03-16-2020 07:30 PM is correct format to convert
to convert use below code :

 var fdate = kitem.last_update;  // ie "16-03-2020 07:30PM";
       var res = fdate.split(" ");
          var time_ = res[1];
          var time_split = time_.substring(0, 4);
          var time_split_AMPM = time_.substring(5, 7);
          var final_time = time_split + ' ' + time_split_AMPM;
       
 var date_ = res[0];
     var dateARR = date_.split("-");
          var final_date = (dateARR[1]+'-'+dateARR[0]+'-'+dateARR[2]);
         var final_dateTime =   final_date + ' ' +final_time;
    var ISOformat = new Date(final_dateTime).toISOString(); 
          resolve(ISOformat);

Comments

Popular posts from this blog

config aggregate and map