Me gustaría mostrar mi marca de tiempo en el frente como la fecha. Probé varios métodos pero ninguno funcionó. aqui esta el codigo:`
formulaire.addEventListener('submit', posteValidation); /** * Fonction pour ajouter une publication dans le serveur * @param {Event} event */ const addPosteServeur = async (event) => { event.preventDefault(); if(formulaire.checkValidity()){ let data = { id_user: 1, timestamps: date.getTime(), text : textPoste.value } let response = await fetch('/', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data) }); if(response.ok){ addPosteClient({ id_user: 1, timestamps: date.getTime(), text: textPoste.value }); textPoste.value = ''; } } } formulaire.addEventListener('submit', addPosteServeur);`Gracias
para obtener la fecha como marca de tiempo en Node.js simplemente haga Date.now() . Si desea obtener la fecha como cadena, puede usar new Date().toUTCString() Le sugiero que lea la API de fecha que se puede encontrar aquí https://developer.mozilla.org/en-US/docs/ Web/JavaScript/Referencia/Global_Objects/Fecha