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

134
Views
cómo administrar la marca de tiempo de los mensajes de texto para la aplicación de chat

De hecho, estoy creando una aplicación de chat y usando reaccionar y cuando envío un mensaje, toma mi hora local y lo guardo en la base de datos y usando la biblioteca socket io, el receptor recibirá el mensaje, el problema es primero, funcionará bien si ambos remitentes y el receptor tienen la misma zona horaria, pero si tienen diferentes zonas horarias, dirá justo ahora para el remitente, pero para el receptor hace 5 horas, cómo solucionarlo, ¿hay alguna biblioteca o es una forma de corregir el código?

y también estoy usando timeago.js para formatear la marca de tiempo como, hace un momento, hace 4 horas...

//lado del remitente

 const socketMessage = { _id:uuid(), conversationId, senderId: user?._id, textMessage, username: currentChat.username, createdAt: new Date(), senderUsername: user?.username, }; socket.emit("sendMessage", socketMessage);

//lado del receptor

 useEffect(() => { let mounted = true; socket?.on("getMessage", (data) => { if (mounted) { setArrivalMessage({ _id: data._id, conversationId: data.conversationId, senderId: data.senderId, textMessage: data?.textMessage, createdAt: data.createdAt, }); } }); return () => { mounted = false; }; }, [socket]);
about 4 years ago · Juan Pablo Isaza
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!