Im currently displaying a timestamp attached to each message sent in a message App Im building. However every stack overflow question I found on converting timestamps has to do with angular or native and I am trying to do this in react. Was wondering what code would I use to display something like (ex: 2/8/2018 11:04am || or something similar).
The current .push to the message array im using is:
this.messagesRef.push(
{
content: this.state.userMsg,
roomId: this.props.activeRoom.key,
username: (this.props.user ? this.props.user.displayName : 'guest'),
sentAt: this.props.firebase.database.ServerValue.TIMESTAMP
}
);
My git hub push for this was (Git Link)
date-fns
to transform the timestamp to something more readable like what you have above?