Hola, he tratado hace un rato de organizar el codigo para que no me aparezca en la app invalid date pero me sigue apareciendo, ayuda :(
He copiado el codigo del profesor incluso pero me sigue apareciendo
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TODO App</title>
<link rel="icon" type="image/png" href="./assets/rocket.svg" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Dosis&family=Open+Sans&family=Parisienne&display=swap"
rel="stylesheet"
/>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<main>
<div class="mainCard">
<div class="title"><img src="./assets/rocket.svg" /></div>
<div>
<form action="">
<input
type="text"
name="task"
placeholder="Nombre de la tarea"
class="inputForm"
autocomplete="off"
data-form-input
/>
<input type="datetime-local" data-form-date placeholder="DD/MM/YYYY"/>
<button type="submit" class="btnCreate" data-form-btn>
Agregar <i class="fas fa-plus-circle"></i>
</button>
</form>
</div>
<ul class="cardsList" data-list>
</ul>
</div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script type="module" src="/script.js"></script>
</body>
</html>
JS
import checkComplete from './components/checkComplete.js';
import deleteIcon from './components/deleteIcon.js';
const btn = document.querySelector('[data-form-btn]');
const addTask = (evento) => {
const list = document.querySelector('[data-list]');
const task = createTask(evento);
list.appendChild(task);
};
const createTask = (evento) => {
evento.preventDefault();
const input = document.querySelector('[data-form-input]');
const calendar = document.querySelector('[data-form-date]');
const value = input.value;
const date = calendar.value;
const dateFormat = moment(date).format('DD/MM/YYYY');
console.log (dateFormat);
const task = document.createElement('li');
task.classList.add('card');
input.value = '';
//backticks
const taskContent = document.createElement('div');
const taskObj = {
value,
dateFormat
}
sessionStorage.setItem('tasks', JSON.stringify (taskObj));
const titleTask = document.createElement('span');
titleTask.classList.add('task');
titleTask.innerText = value;
taskContent.appendChild(checkComplete());
taskContent.appendChild(titleTask);
// task.innerHTML = content;
const dateElement = document.createElement('span');
dateElement.innerHTML = dateFormat;
task.appendChild(taskContent);
task.appendChild(dateElement);
task.appendChild(deleteIcon());
return task;
};
//Arrow functions o funciones anonimas
btn.addEventListener('click', addTask);