Newskit Logo

Getting started

Design overview

Popular searches

View GitHub

Text

Date Time

The date time component is a styled, HTML5 time element for displaying date and time.

Status

Supported

Introduced

v0.18.0

View codeView StorybookView Design

Interactive demo

This demo lets you preview the date time component, its variations, and configuration options.

Updated: The Times
Date Time StylePreset
Date Time TypographyPreset
Prefix StylePreset
Prefix TypographyPreset
Suffix StylePreset
Suffix TypographyPreset
1import React from 'react';
2import { DateTime } from 'newskit';
3
4export default () => (
5  <DateTime
6    date="2017-07-01T14:32:00.000Z"
7    dateFormat="MMMM d yyyy, h:mmaaaaa'm'"
8    prefix="Updated: "
9    suffix="The Times"
10    overrides={{ prefix: {}, suffix: {} }}
11  />
12);
13

Anatomy

Date time contains one required element.

ItemNameDescriptionComponentOptional

Options

The date time has options for different use cases:

Prefix

Text placed in front of the date and time, separated by a space.

Suffix

Text placed after the date and time, separated by a comma and a space.

Date and time format

Specify a format for displaying the date and time. See date-fns docsfor the available settings.

Prefix

Text placed in front of the date and time, separated by a space.

Suffix

Text placed after the date and time, separated by a comma and a space.

Date and time format

Specify a format for displaying the date and time. See date-fns docsfor the available settings.

Usage

Here’s how and when to use the date time component:

Do consider the appropriate format for your users

In British English, the month follows the day. In American English, the month precedes the day.

Accessibility considerations

The Date Time component is wrapped in an HTML5 time element. The date prop provided is passed into its datetime attribute to make the date displayed fully accessible.

API

Date Time

Date time has a range of props that can be used to define an appropriate experience for different use cases.

NameTypeDefaultDescriptionRequired

Need Help?

Cant find what you are looking for?

Get In Touch

Need Help?

Cant find what you are looking for?