mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-22 21:08:12 +08:00
feat(curriculum): Add interactive examples to date/time lesson (#62699)
This commit is contained in:
parent
b6588b005c
commit
747b1ebebd
@ -5,16 +5,20 @@ challengeType: 19
|
||||
dashedName: how-do-you-display-times-and-dates-in-html
|
||||
---
|
||||
|
||||
# --description--
|
||||
# --interactive--
|
||||
|
||||
The `time` element is used to represent a specific moment in time.
|
||||
|
||||
Here is an example using the `time` element to represent twenty hundred hours, or eight PM in the evening.
|
||||
|
||||
:::interactive_editor
|
||||
|
||||
```html
|
||||
<p>The reservations are for <time datetime="20:00">20:00 </time></p>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
The `datetime` attribute is used to translate dates and times into a machine-readable format.
|
||||
|
||||
This is important, because it helps with search engine results and helps the browser process date and time information more effectively.
|
||||
@ -23,12 +27,16 @@ The value for the `datetime` attribute must be either a valid year, valid month,
|
||||
|
||||
Here is another example of using the time element to represent a particular date:
|
||||
|
||||
:::interactive_editor
|
||||
|
||||
```html
|
||||
<p>
|
||||
The graduation will be on <time datetime="2024-06-15T15:00">June 15</time>
|
||||
</p>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
The value for the `datetime` attribute is in the ISO 8601 format. ISO 8601 is an international standard to represent dates and times.
|
||||
|
||||
The first part of that value is the year, month and day. The capital T in the value is a separator between the date and time.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user