From 734f24b3c632ad04291ca08556fac73eff1cc081 Mon Sep 17 00:00:00 2001 From: Oshanwick Date: Sat, 3 Oct 2020 23:42:06 +0530 Subject: [PATCH] add timestamp to messeage --- src/App.css | 10 +++++++--- src/App.js | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/App.css b/src/App.css index 70ebe18..0645b7b 100644 --- a/src/App.css +++ b/src/App.css @@ -115,7 +115,7 @@ ul, li { list-style: none; } -p { +p1 { max-width: 500px; margin-bottom: 12px; line-height: 24px; @@ -136,12 +136,12 @@ p { flex-direction: row-reverse; } -.sent p { +.sent p1 { color: white; background: #0b93f6; align-self: flex-end; } -.received p { +.received p1{ background: #e5e5ea; color: black; } @@ -152,4 +152,8 @@ img { border-radius: 50%; margin: 2px 5px; } +p { + font-size: 10px; + +} diff --git a/src/App.js b/src/App.js index d7c9417..cb921ae 100644 --- a/src/App.js +++ b/src/App.js @@ -107,14 +107,16 @@ function ChatRoom() { function ChatMessage(props) { - const { text, uid, photoURL } = props.message; + + const { text, uid, photoURL, createdAt } = props.message; + var n = new Date(createdAt * 1000).toLocaleTimeString() const messageClass = uid === auth.currentUser.uid ? 'sent' : 'received'; return (<>
-

{text}

+ {text}

{n}

) }