Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda