Adrian
Adrian

Reputation: 20078

How to set only AM time for an UIDatePicker?

Right now I am using an UIDatePicker with mode set to Time only. So I can choose between AM and PM time.

Is there a way to prevent choosing PM time ? My app is using a morning routine so there is no point on selecting PM time.

At least I want to always show an AM time, right now it displays the current time (so if it's PM, I have to change it to AM).

Upvotes: 0

Views: 94

Answers (1)

matt
matt

Reputation: 536047

Set the date picker's minimumDate to midnight and its maximumDate to noon. Also, if (as you say) it is currently after noon, set the date picker's date to 12 hours earlier.

Upvotes: 1

Related Questions