Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!