Time field
The time field stores a timestamp in milliseconds to represent a time value.
Examples
Here's an example of using the time field in a block:
# blocks/TimeOffset.vue
<template>
<span>Alert: {{ alert ? new Date(alert).toLocaleTimeString() : 'None' }}</span>
</template>
<script lang="ts" setup>
import { timeField } from '#pruvious'
defineProps({
alert: timeField({
placeholder: 'Pick a time',
}),
})
</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: {
dailyAlert: {
type: 'time',
options: {
placeholder: 'Pick a time',
},
},
// ...
},
})
Options
You can specify the following options in the 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, eventTime becomes Event time. |
| The latest possible time (as timestamp in milliseconds). This value should not exceed 86399999 ms. |
| The earliest possible 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. |
Last updated on January 6, 2024 at 18:07