Time input with 1 second resolution

Summary

I need to input time values with 1 second resolution, but if I try typing in a value such as 12:34:56 the time widget rejects it. Only HH:MM such as 12:34 is allowed.

Expected behavior:

If i type in a valid time with seconds included, the widget should accept it.

Actual behavior:

Any time value I type that includes seconds is rejected.

Debug info

  • Streamlit version: 1.12
  • Python version: 3.9
  • Using Conda
  • OS version: Win 10
  • Browser version: Chrome 111

Looking at the source code, it looks like seconds and milliseconds are scrubbed internally, so I don’t really see a cheeky way around it:

time_input_proto.default = time.strftime(parsed_time, "%H:%M")

I did a quick search and didn’t see an active feature request for this, so you may consider adding a feature request to github to expand the time_input widget:

To get around it, I think either look at a custom component or use multiple widgets to set hours, minutes, and seconds separately and combine them into a time object.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.