TimeTagHelper Class
Converts a DateTimeOffset value to a properly formatted datetime attribute for HTML elements.
public sealed class TimeTagHelper : TagHelperRemarks
The value is normalized to UTC and always written with the Z designator. A datetime attribute without a time zone designator is interpreted as local time by the reader, which would shift the value by the reader's UTC offset.
Example
<time datetime-value="@DateTimeOffset.UtcNow">Just now</time>
@* Rendered as <time datetime="2024-01-15T10:30:45.123Z">Just now</time> *@- Inheritance
TagHelperTimeTagHelper
Constructors
| Name | Description |
|---|---|
| TimeTagHelper() |
TimeTagHelper()
public TimeTagHelper()No documentation is available.
Properties
| Name | Description |
|---|---|
| Datetime | Gets or sets the date and time to format for the datetime attribute. |
Datetime
TimeTagHelper.csGets or sets the date and time to format for the datetime attribute.
public DateTimeOffset? Datetime { get; set; }Property value
Methods
| Name | Description |
|---|---|
| Process(TagHelperContext, TagHelperOutput) | Processes the tag helper and sets the datetime attribute in ISO 8601 format. |
Process(TagHelperContext, TagHelperOutput)
TimeTagHelper.csProcesses the tag helper and sets the datetime attribute in ISO 8601 format.
public override void Process(TagHelperContext context, TagHelperOutput output)Parameters
contextTagHelperContextoutputTagHelperOutput