Skip to main content

Date Time Input

The Date Time Input widget provides a specialized input field for selecting both date and time with calendar and time picker interfaces.

States

StateTypeDefaultDescription
valuestringNoneCurrent selected date and time value

Properties

PropertyTypeDefaultDescription
labelstring""Label text displayed above the input
placeholderstring""Placeholder text displayed when no date/time is selected
default_valuestringNoneInitial date and time value
requiredboolFalseWhether a date and time selection is required
disabledboolFalseWhether the input is disabled
formatstring"YYYY-MM-DD HH:mm:ss"Format string for date and time display
max_valuestringNoneMaximum selectable date and time
min_valuestringNoneMinimum selectable date and time

Examples

Basic Date Time Input

package main

import (
"github.com/trysourcetool/sourcetool-go"
"github.com/trysourcetool/sourcetool-go/datetimeinput"
)

func main() {
func page(ui sourcetool.UIBuilder) error {
// Create a basic date time input
dateTimeInput := ui.DateTimeInput("Date Time", datetimeinput.Placeholder("Select date and time"))
}
}

Date Time Input with Custom Format

// Create a date time input with custom format
dateTimeInput := ui.DateTimeInput("Date Time", datetimeinput.Placeholder("Select date and time"), datetimeinput.Format("YYYY-MM-DD HH:mm"))

Date Time Input with Range Constraints

// Create a date time input with range constraints
dateTimeInput := ui.DateTimeInput("Date Time", datetimeinput.Placeholder("Select date and time"), datetimeinput.MinValue(time.Now()), datetimeinput.MaxValue(time.Now().AddDate(0, 0, 30)))

Disabled Date Time Input with Default Value

// Create a disabled date time input with a default value
dateTimeInput := ui.DateTimeInput("Date Time", datetimeinput.Placeholder("Select date and time"), datetimeinput.DefaultValue(time.Now()))
  • DateInput - For selecting only a date without time
  • TimeInput - For selecting only time without a date