Formatting date_input input fields #5634
-
First Check
Example Codefrom nicegui import ui
import datetime
current = datetime.now().isoformat()
date = ui.date_input(label="Date", value="").props('mask="DD/MM/YYYY"')
ui.run()DescriptionIs there a way to format the input/output of the date_input control when it receives a ISO timestamp to only show the date in a specific format? so the input and output value would be YYYY-MM-DDTHH:MM:SSZ, but the displayed value on the date input would be DD/MM/YYYY. I've tried the mask and other methods to no avail. I've checked all the documentation but I cant see anything solid. Thanks. NiceGUI Version3.3 Python Version3.12.10 BrowserChrome Operating SystemWindows Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Hello @DylanBrianBenton
Checking #4815,
@DylanBrianBenton @platinops Do you think we should pursue |
Beta Was this translation helpful? Give feedback.
-
|
If it's ok to hold the value in its localized form, you can convert it initially and adjust the picker mask: now = datetime.now()
date = ui.date_input('Date', value=datetime.strftime(now, '%d.%m.%Y'))
date.picker.props('mask="DD.MM.YYYY"')If you want to hold the value in its original form but display it localized, you most probably need to implement your own value element. |
Beta Was this translation helpful? Give feedback.
If it's ok to hold the value in its localized form, you can convert it initially and adjust the picker mask:
If you want to hold the value in its original form but display it localized, you most probably need to implement your own value element.
ui.date_input, which derives fromui.input, usually displays its underlying, untransformed value.