Date-time field
The date-time field stores a timestamp in milliseconds to represent a date-time value.
Examples
Here's an example of using the date-time field in a block:
# blocks/Product.vue
<template>
<div>
<span v-if="!publishDate || Date.now() > publishDate">Available</span>
<span v-else>Not available</span>
...
</div>
</template>
<script lang="ts" setup>
import { dateTimeField } from '#pruvious'
defineProps({
publishDate: dateTimeField({
description: 'The date and time when the product is published or scheduled for publication.',
}),
})
</script>
Here is another example of how to use it in a collection definition:
# collections/products.ts
import { defineCollection } from '#pruvious'
export default defineCollection({
name: 'products',
mode: 'multi',
fields: {
releaseDate: {
type: 'date-date',
options: {
description: 'The date and time when the product is published or scheduled for publication.',
},
},
// ...
},
})
Options
You can specify the following options in the date-time field:
Option | Description |
---|---|
| A boolean indicating whether to display a clear button that removes the current value. |
| The default field value ( |
| A brief descriptive text displayed in code comments and in a tooltip at the upper right corner of the field. |
| The field label displayed in the UI. By default, it is automatically generated based on the property name assigned to the field. For example, eventDate becomes Event date. |
| The latest possible date and time (as timestamp in milliseconds). |
| The earliest possible date and time (as timestamp in milliseconds). |
| A string that specifies the |
| Text that appears in the input element when it has no value set. |
| Specifies that the field input is mandatory during creation. |
| A boolean flag indicating whether to use UTC time in the date-time picker. The stored value is always in UTC. The default setting is |
Last updated on January 6, 2024 at 17:29