How can I change the time and date format in sendbird ui kit (react native)

I am using sendbird ui kit for react native. Is there any way to change the date format to something like this :

  • in channel list , the last message should be rendered as 2 days ago or 10 mnts/seconds ago. As of now, it shows the time of the last message eg. 12.12 pm or 3/1/24.
  • in group channel message list, instead of showing the today’s date , can we show the date label as today, yesterday and then the dates. As of now, it always shows the date.
    I have attached a few ss for the use-cases. Please do have a look.
    Thanks


Hello @Sumit_Dey
you can customize date format using StringSet.

import { SendbirdUIKitContainer, createBaseStringSet } from '@sendbird/uikit-react-native';
import { formatDistance } from 'date-fns';
import dateLocale from 'date-fns/locale/en-US';

const myStringSet = createBaseStringSet({
  dateLocale,
  overrides: {
    GROUP_CHANNEL_LIST: {
      CHANNEL_PREVIEW_TITLE_CAPTION: (channel) => {
        if (!channel.lastMessage) return '';
        return formatDistance(channel.lastMessage.createdAt, Date.now(), { addSuffix: true, locale: dateLocale });
      },
    },
  },
});


const App = () => {
  return <SendbirdUIKitContainer localization={{ stringSet: myStringSet }} />
}

image