Time

Struct Time 

Source
pub struct Time;
Expand description

The <time> element - date and/or time.

§Purpose

The <time> element represents a specific time or date, optionally with a machine-readable timestamp in the datetime attribute. It helps search engines and other software understand temporal information.

§Content Categories

  • Flow Content
  • Phrasing Content
  • Palpable Content

§Permitted Content Model

  • Phrasing content (but no <time> descendants)

§Common Use Cases

  • Publication dates
  • Event dates and times
  • Deadlines and schedules
  • Historical dates
  • Time-based content

§Key Attributes

  • datetime: Machine-readable date/time (ISO 8601 format)
  • Global attributes

§Example

<p>Posted on <time datetime="2024-01-15">January 15, 2024</time></p>
<p>Event starts at <time datetime="2024-06-20T19:00">7:00 PM on June 20</time></p>
<p>Updated <time datetime="2024-01-15T14:30:00Z">today at 2:30 PM</time></p>
<time datetime="2024">2024</time>

§Accessibility

  • Provides semantic meaning for dates and times
  • datetime attribute aids machine parsing

§WHATWG Specification

Trait Implementations§

Source§

impl HtmlElement for Time

Source§

const TAG: &'static str = "time"

The HTML tag name (e.g., “div”, “span”, “img”).
Source§

const VOID: bool = false

Whether this is a void element (self-closing, no children allowed).
Source§

impl<T: PhrasingContent> CanContain<T> for Time

Source§

impl CanContain<Text> for Time

Source§

impl FlowContent for Time

Source§

impl PalpableContent for Time

Source§

impl PhrasingContent for Time

Auto Trait Implementations§

§

impl Freeze for Time

§

impl RefUnwindSafe for Time

§

impl Send for Time

§

impl Sync for Time

§

impl Unpin for Time

§

impl UnwindSafe for Time

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.