Timestamp
On this page
On this page
Installation
We recommend import maps when building pages with RHDS. Learn more about how to install on our getting started docs.
<script type="importmap">
{
"imports": {
"@rhds/elements/": "https://www.redhatstatic.com/dx/v1-alpha/@rhds/elements@2.1.2/elements/",
}
}
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
npm install @rhds/elements
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
<script type="importmap">
Could not generate import map using JSPM: Cannot read properties of undefined (reading '@rhds/elements')
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow 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
Copied!
Wrap lines
Overflow 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
Copied!
Wrap lines
Overflow lines
rh-timestamp
A timestamp provides consistent formats for displaying date and time values.
Attribute | DOM Property | Description | Type | Default |
---|---|---|---|---|
date-format |
dateFormat |
Custom date formatting style. See MDN for options. |
|
|
time-format |
timeFormat |
Custom time formatting style. See MDN for options. |
|
|
display-suffix |
displaySuffix |
Text to display after the timestamp |
|
|
locale |
locale |
Overrides the runtime's default locale |
|
|
relative |
relative |
Formats a timestamp in realtive terms |
|
|
utc |
utc |
Sets the timezone as UTC |
|
|
hour-12 |
hour12 |
Whether to use 12-hour time (as opposed to 24-hour time) |
|
|
date |
date |
A string value representing a date |
|
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.