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

269
Views
mostrando la fecha/hora de MongoDB como hace X minutos/horas/segundos

Obtengo fechas de 2 puntos finales de API diferentes y las guardo en MongoDB usando Mongoose (fecha usada en el esquema).

Aquí hay un ejemplo de las 2 fechas en la base de datos. Usando dayjs, uno de ellos funciona correctamente y el otro se muestra in 2 hours en lugar de X minutes ago por ejemplo.

 correct: 2022-01-11T16:05:05.000+00:00 incorrect: 2022-01-11T17:41:50.000+00:00 import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; dayjs.extend(relativeTime); {dayjs(data.paperDate).fromNow()} // returns 'in 2 hours'

¿Hay algún problema con la fecha marcada como 'incorrecta'?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

ver https://momentjs.com/docs/

 moment(new Date(2021)).fromNow(); // a year ago moment(new Date(2021)).from(new Date(2012))
over 4 years ago · Santiago Trujillo 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!