Skip to content

v-datetime

Formats and displays ISO datetime strings. By default, input is treated as UTC and converted to local time for display.

Usage

vue
<!-- Default format (from config) -->
<span v-datetime="'2024-01-15T10:30:00Z'"></span>

<!-- Date only -->
<span v-datetime="isoDate" date-only></span>

<!-- Custom format (date-fns syntax) -->
<span v-datetime="isoDate" format="MMM d, yyyy"></span>

<!-- Relative: shows time if today, full date otherwise -->
<span v-datetime="isoDate" relative-date></span>

<!-- Simplified: hides date if today, hides year if current year -->
<span v-datetime="isoDate" simplified-date></span>

<!-- Treat input as local time (don't assume UTC) -->
<span v-datetime="localDate" local></span>

<!-- Display in UTC -->
<span v-datetime="isoDate" display-utc></span>

<!-- Placeholder when null -->
<span v-datetime="null" placeholder="N/A"></span>

Modifiers

AttributeDescription
date-onlyShow date without time
formatCustom date-fns format string
relative-dateShow time if today, full date otherwise
simplified-dateHide date if today, hide year if current year
localTreat input as local time instead of UTC
display-utcDisplay the output in UTC
placeholderText to show when the value is null

Demo