Timestamp

OverviewStyleGuidelinesCodeAccessibilityDemos

Installation

We recommend import maps when building pages with RHDS. Learn more about how to install on our getting started docs.

Red Hat CDN
<script type="importmap">
{
  "imports": {
    "@rhds/elements/": "https://www.redhatstatic.com/dx/v1-alpha/@rhds/elements@2.1.2/elements/",
  }
}
</script>
Copy to Clipboard Wrap lines
NPM
npm install @rhds/elements
Copy to Clipboard Wrap lines
JSPM
<script type="importmap">
Could not generate import map using JSPM: Cannot read properties of undefined (reading '@rhds/elements')
</script>
Copy to Clipboard Wrap lines

Add it to your page with this import statement

<script type="module">
  import '@rhds/elements/rh-timestamp/rh-timestamp.js';
</script>
Copy to Clipboard Wrap lines

Usage

<rh-timestamp date="Tue Aug 09 2006 14:57:00 GMT-0400"></rh-timestamp>

<script type="module">
  import '@rhds/elements/rh-timestamp/rh-timestamp.js';
</script>
Copy to Clipboard Wrap lines

rh-timestamp

A timestamp provides consistent formats for displaying date and time values.

Slots 0
None
Attributes 8
Attribute DOM Property Description Type Default
date-format dateFormat

Custom date formatting style. See MDN for options.

DateTimeFormat | undefined
unknown
time-format timeFormat

Custom time formatting style. See MDN for options.

DateTimeFormat | undefined
unknown
display-suffix displaySuffix

Text to display after the timestamp

string | undefined
unknown
locale locale

Overrides the runtime's default locale

string | undefined
unknown
relative relative

Formats a timestamp in realtive terms

boolean | undefined
unknown
utc utc

Sets the timezone as UTC

boolean | undefined
unknown
hour-12 hour12

Whether to use 12-hour time (as opposed to 24-hour time)

boolean | undefined
unknown
date date

A string value representing a date

unknown
unknown
Methods 0
None
Events 0
None
CSS Shadow Parts 0
None
CSS Custom Properties 0
None
Design Tokens 0
None