Timestamp
Importing
Add rh-timestamp 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
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
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.