skip to Main Content

I need to format messages on the same day like below:
enter image description here
enter image description here

I store message data in mongodb, the frontend I use reactjs and the backend uses nodejs code according to typescript, I need to process it to get it like the image I provided.

2

Answers


  1. Try this

    let now = new Date();
    
    let options = { year: 'numeric', month: 'long', day: 'numeric' };
    
    console.log("Formatted Datetime:", now.toLocaleDateString("en-US", options));
    
    Login or Signup to reply.
  2. You can use similar function like this to display the dates,

    https://stackoverflow.com/questions/61237564/how-can-i-show-days-by-group-like-whatsapp-chat-screen

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search