Tengo una respuesta de mydatepicker en el siguiente formato
{ "isRange":false, "singleDate":{ "date":{ "year":2022, "month":5, "day":13 }, "jsDate":"2022-05-13T03:00:00.000Z", "formatted":"13-05-2022", "epoc":1652410800 }, "dateRange":null }Tengo un filtro que usa la nueva fecha(), pero parece que no lo acepta aceptando la fecha en el valor dd-mm-yyyy y necesitaría mostrarlo así, no así yyyy-mm- dd
filterPeriodos() { const d = new Date(this.formGeral.value.data.singleDate?.formatted + 'T23:59'); if (this.storeS.layout.emp.id === 1) { if(this.formGeral.value.entregaBool){ return this.periodos.filter( transpId => transpId.ativo === (1) && transpId.transporte_id === (this.metodoId) && transpId.week[d.getDay()] === 1 ) ; } } return this.periodos; }¿Alguien tiene alguna sugerencia?
Para obtener el final de un día, primero convierta el texto analizable en una fecha, luego manipule esa fecha.
let object = this.formGeral.value.data; // for our sanity let jsDate = new Date(object.singleDate.jsDate); jsDate.setUTCHours(23,59,59,999); Mantenga la cadena formatted para mostrarla, pero realice cualquier cálculo de fecha en el objeto de fecha real.