TimeEntry restricted to 24h format

How can I ensure the time-entry input is only rendered in 24h (ie no AM/PM options)?
14 Replies
toeknee
toeknee4mo ago
use time picker? TimePicker::make('alarm_at')
Dan Harrin
Dan Harrin4mo ago
I think you just want to change the displayFormat()?
islandnuge
islandnugeOP4mo ago
I've tried using that but maybe don't understand exactly how to leverage the formatting. I get this with
TimePicker::make('end_time')
->label('End Time')
->displayFormat('H:i')
->columnSpan(1),
TimePicker::make('end_time')
->label('End Time')
->displayFormat('H:i')
->columnSpan(1),
But am trying to get the first list to be 0-24, and hide the AM/PM selection. Even better if I can hide the seconds but thats not huge if not. Shouldn't H:i do this?
No description
Dan Harrin
Dan Harrin4mo ago
you need to use native(false) your browser doesnt have that control for am/pm
Kaesa Lyrih
Kaesa Lyrih4mo ago
is documented how to change am/pm into 24h, TimerPicker & DateTimePicker?
Dan Harrin
Dan Harrin4mo ago
its just the native browser behaviour not filament if you want to turn off the native browser behaviour you need to use native(false) as i said. the method is documented or maybe there is a browser/os setting, google it
Kaesa Lyrih
Kaesa Lyrih4mo ago
This is new knowledge for me. Thanks for the information. Can you make documentation about it, how to make it 24h instead of 12h AM|PM? So that this question is not repeated.
Dan Harrin
Dan Harrin4mo ago
i also dont get why someone would disable am/pm input if that is what their current locale uses each locale on your OS has a different preference for that
Tim van Heugten
Tim van Heugten4mo ago
I guess being in one country as a developer building something for an audience in another country. You demo something, client says “No am/pm!” and then you start searching as you’re not familiar with native inputs (this is all going off assumptions). Anyway, I think this less of an issue for US/UK devs building for their own local audiences.
Dan Harrin
Dan Harrin4mo ago
on the other hand, I dont want to worry about where my user is based some of my users might want am/pm, some might not so again I don't want to control that for them 🤷‍♂️
Tim van Heugten
Tim van Heugten4mo ago
I’m with you here. Just trying to come up with an explanation I do sometimes like to make it an app setting for the user and stick to that instead of relying on the locale. Especially with like expat employees etc. Again very dependent on the audience.
toeknee
toeknee4mo ago
Maybe ask the user to test it or set your browser locale to the country the app is being developed for?
islandnuge
islandnugeOP3mo ago
follow-up on this - we were able to convince the client to accept the am/pm as a 'device and locale' standard (as you suggested) - very much appreciated!

Did you find this page helpful?