Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
Get date from timestamp in node js

I would like to display my timestamp in the front as the date. I tried several methods but none worked. here is the code:`

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);`

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

to get the date as timestamp in Node.js simply do Date.now(). If you want to get the date as string, you can use new Date().toUTCString() I suggest you to read the Date API that can be found here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda