Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-release-flutter-v5-stable.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

FieldValue
Package@cometchat/chat-uikit-angular
Key classCometChatLocalize (global CalendarObject management)
Key componentCometChatDateComponent (cometchat-date element)
Required setupCometChatUIKit.init(uiKitSettings)
PurposeCustomize date/time formatting globally, per-component, or per-language
FeaturesLanguage-specific defaults, global override, per-instance override, relative time
RelatedLocalization | Theming
CometChat UIKit provides flexible date/time formatting with language-aware defaults. Dates automatically adapt when you switch languages, and you can override formats globally or per-component.
CapabilityDescription
Language-specific defaultsDate formats auto-adapt per language (e.g., MM/DD/YYYY for en-US, DD/MM/YYYY for en-GB)
Global overrideSet a custom CalendarObject that applies to all components
Per-component overridePass a CalendarObject input to individual cometchat-date instances
Relative timeConfigure “X minutes ago” style formatting
Timezone supportSet timezone globally via CometChatLocalize

How It Works

The cometchat-date component resolves its date format using a fallback chain:
  1. Component [calendarObject] input (highest priority)
  2. Global CalendarObject from CometChatLocalize.getCalendarObject()
  3. Hardcoded fallback: hh:mm A / [Yesterday] / dddd / DD/MM/YYYY

Language-Specific Defaults

When you switch languages, date formats automatically adapt:
LanguageTodayYesterdayOther Days
en-UShh:mm A[Yesterday]MM/DD/YYYY
en-GBHH:mm[Yesterday]DD/MM/YYYY
deHH:mm[Gestern]DD.MM.YYYY
frHH:mm[Hier]DD/MM/YYYY
esHH:mm[Ayer]DD/MM/YYYY
jaHH:mm[昨日]YYYY/MM/DD
koHH:mm[어제]YYYY/MM/DD
zhHH:mm[昨天]YYYY/MM/DD
ruHH:mm[Вчера]DD.MM.YYYY
svHH:mm[Igår]YYYY-MM-DD
// Switching language automatically updates date formats
CometChatLocalize.setCurrentLanguage('ja');
// Dates now show YYYY/MM/DD format with Japanese "yesterday" label

Global Date Format Override

Set a custom CalendarObject that applies to all cometchat-date instances:
import { CometChatLocalize } from '@cometchat/chat-uikit-angular';

// Set global date format
CometChatLocalize.setGlobalCalendarObject({
  today: 'HH:mm',
  yesterday: '[Yesterday] HH:mm',
  lastWeek: 'dddd HH:mm',
  otherDays: 'DD/MM/YYYY'
});
Once you set a custom global CalendarObject, switching languages will NOT override it. Your custom format is preserved across language changes. To revert to language-specific defaults, you would need to reset the CalendarObject.

Via Initialization

CometChatLocalize.init({
  language: 'en-US',
  calendarObject: {
    today: 'h:mm A',
    yesterday: '[Yesterday] h:mm A',
    lastWeek: 'dddd h:mm A',
    otherDays: 'MMM DD, YYYY'
  }
});

Per-Component Override

Pass a calendarObject input to individual cometchat-date instances:
<cometchat-date
  [timestamp]="message.getSentAt()"
  [calendarObject]="customFormat">
</cometchat-date>
customFormat: CalendarObject = {
  today: 'HH:mm:ss',
  yesterday: '[Yesterday] HH:mm',
  lastWeek: 'ddd DD MMM',
  otherDays: 'DD MMM YYYY'
};
The component input always takes priority over the global CalendarObject.

CalendarObject Reference

interface CalendarObject {
  today?: string;       // Format for today's dates
  yesterday?: string;   // Format for yesterday's dates
  lastWeek?: string;    // Format for dates within last 7 days
  otherDays?: string;   // Format for all other dates
  relativeTime?: {
    minute?: string;    // "1 minute ago" (use %d for number)
    minutes?: string;   // "X minutes ago" (use %d for number)
    hour?: string;      // "1 hour ago" (use %d for number)
    hours?: string;     // "X hours ago" (use %d for number)
  };
}

Format Tokens

TokenOutputExample
YYYY4-digit year2026
YY2-digit year26
MM2-digit month03
DD2-digit day23
ddddFull weekdayMonday
dddShort weekdayMon
HH24-hour hour14
hh12-hour hour02
mmMinutes30
AAM/PMPM
[text]Literal text[Yesterday] → Yesterday

Relative Time

Enable “X minutes ago” style formatting:
CometChatLocalize.setGlobalCalendarObject({
  today: 'hh:mm A',
  yesterday: '[Yesterday]',
  lastWeek: 'dddd',
  otherDays: 'DD/MM/YYYY',
  relativeTime: {
    minute: '1 minute ago',
    minutes: '%d minutes ago',
    hour: '1 hour ago',
    hours: '%d hours ago'
  }
});
When relativeTime is configured, recent messages show relative timestamps instead of absolute times.

Timezone

// Set timezone globally
CometChatLocalize.init({
  language: 'en-US',
  timezone: 'America/Los_Angeles'
});

// Or check current timezone
const tz = CometChatLocalize.getTimezone();

Example: Custom Date Formats

import { Component, OnInit } from '@angular/core';
import { CometChatLocalize } from '@cometchat/chat-uikit-angular';

@Component({
  selector: 'app-root',
  template: `<cometchat-message-list [user]="user"></cometchat-message-list>`
})
export class AppComponent implements OnInit {
  ngOnInit() {
    // All dates in the app use this format
    CometChatLocalize.setGlobalCalendarObject({
      today: 'h:mm A',
      yesterday: '[Yesterday] h:mm A',
      lastWeek: 'ddd, MMM DD',
      otherDays: 'MMM DD, YYYY',
      relativeTime: {
        minute: 'Just now',
        minutes: '%d min ago',
        hour: '1 hr ago',
        hours: '%d hrs ago'
      }
    });
  }
}

Next Steps

Localization

Override translations globally or per-component.

Theming

Customize colors, fonts, and spacing.

Custom Message Types

Add custom message types with templates.

Global Config

Configure global UIKit settings.