I'm building a chat app so when a user sends message, a time stamp is also sent in database. I followed this answer for this implementation.
database()
        .ref('/')
        .child(`chats/${merged_uid}/${+new Date()}`)
        .set({
          message: msgInput,
          number: current_user.phoneNumber,
          uid: current_user.id,
          time: +new Date(),
        });
and i'm rendering this time stamp in my app in a flatlist in following way
<Text style={styles.timeStamp}>
                {new Date(item.time * 1000).getHours() +
                  ':' +
                  new Date(item.time * 1000).getMinutes()}
              </Text>
but my timestamp is not rendering correctly. These are the problems i'm facing with timestamp.
- It's not correct. i.e my current time of message is 4:44pm so it shows 16:50, here hours is correct but mins aren't. and sometimes it just doesn't give time correct. in next following 6 message time was 13:31, 14:35, 16:13, 19:1, 17:44, 20:44 respectively while current time was 4:44pm.
- Time is not formatted. i.e How can i convert it to 12hrs time format
 
     
     
    