Show a simple timestamp anywhere in your app!

Live Demo

When to use #

The Timestamp component renders a simple string showing a date and time. It is shown in an opinionated format that we believe is well suited for messages.

You can use this as a building block alongside other Cord components to build any message layout that you might need. Any timestamps returned from our APIs can be directly passed in and displayed correctly. For example, timestamps returned from our Message REST API.

How to use #

import { Timestamp } from "@cord-sdk/react";

export const Example = () => {
  // Hour ago from current time
  const dateValue = new Date(Date.now() - 1000 * 60 * 60);

  return <Timestamp value={dateValue} />;

Properties #

value #

string | number | Date
The timestamp to display. This can be any format that will be parsed properly by the Date constructor.
The default value is the current time and date.

relative #

When true, timestamps are shown relative to the current time. When false, timestamps are shown in absolute terms.
The default value is set to true.

CSS customization #

If you want to customize this component, you can target the classes below in your app's CSS. These are guaranteed to be stable.

Class nameDescription
Applied to the p containing the timestamp

Ask Cordy