sdy

add moment.js

1 import React from "react"; 1 import React from "react";
2 import styled from "styled-components"; 2 import styled from "styled-components";
3 import ProfileIcon from "./ProfileIcon"; 3 import ProfileIcon from "./ProfileIcon";
4 +import moment from "moment";
4 5
5 const MessageWrapper = styled.div` 6 const MessageWrapper = styled.div`
6 display: flex; 7 display: flex;
...@@ -45,7 +46,8 @@ const Time = styled.span` ...@@ -45,7 +46,8 @@ const Time = styled.span`
45 font-size: 15px; 46 font-size: 15px;
46 `; 47 `;
47 48
48 -export default ({ text, avatar }) => { 49 +export default ({ text, avatar, time }) => {
50 + let UTCTime = moment.utc(time).format("HH:mm");
49 return ( 51 return (
50 <MessageWrapper className="MessageWrapper"> 52 <MessageWrapper className="MessageWrapper">
51 <MsgContainer> 53 <MsgContainer>
...@@ -55,7 +57,7 @@ export default ({ text, avatar }) => { ...@@ -55,7 +57,7 @@ export default ({ text, avatar }) => {
55 <Msg> {text} </Msg> 57 <Msg> {text} </Msg>
56 </MsgBox> 58 </MsgBox>
57 <TimeBox> 59 <TimeBox>
58 - <Time>1</Time> 60 + <Time>{UTCTime}</Time>
59 </TimeBox> 61 </TimeBox>
60 </ColumnBox> 62 </ColumnBox>
61 </MsgContainer> 63 </MsgContainer>
......