I want to display dates in imagepicker within a range, iOS - ios

I want to display dates in UIImagePicker within a range, I have start date and I will select start date and end date should automatically appear for a week, dates from past one week should appear. i.e if start date is 10 and end date should be displayed as 3 and dates should be Populated between 10 to 3 which should be displayed in iOS.

just use the maximumDate and minimumDate properties of UIDatePicker

Related

How create calendar with only custom date selection allow so other date will be disable in UIDatePicker swift

I want to allow user to select only given date from API and other date should be un-clickable or disable.
As I can check in SWIFT UIDatePicker only providing minimum date and maximum date selection but my requirement is to enable random date.

Hide dates after maximum / before minimum in UIDatePicker

I have a UIDatePicker with a minimumDate and maximumDate set. The default UI of the date picker shows all dates, including those before the minimum and after the maximum. If the user spins to an out-of-bounds date, the picker does spin back - but this is not a great user experience. Can I make it so that the picker simply doesn't display out-of-bounds dates?
In my case, this is particularly important because my app deals with historic events. The date picker starts at the current date and allows users to spin back in time. It's faintly ridiculous in this situation to show tomorrow's date below the current date.

Datepicker maximumDate stuck on yesterday day during early time of the current day

I have a date picker that is set to not allow users to pick future dates. It's maximum date is set for the current time on viewDidLoad.
dateDatePicker.maximumDate = NSDate()
But I've been noticing a bug. Today until midday the maximum date was yesterdays date. But now, after midday it is showing todays date.
The way I implemented it: The date picker is shown and hidden with alpha when user wants to use it. So I am setting the maximum date not every time the picker is shown but once it loads the view it is in.
So I am not sure if this is a bug?
Is it has to do with timezones?
Or has to do with the fact that I am only calling dateDatePicker.maximumDate once when they view loaded and that could have happened days ago?
Or if I should reset the maximumDate every time I show the datePicker?
Yes, you should almost certainly set the maximum date each time you show the date picker.
If you set the maximum date on a previous day and then never updated it nor closed the view controller the it wouldn't change.
Set it in viewWillAppear, not viewDidLoad.
If that doesn't work, use NSCalendar and NSDateComponents to build an NSDate which is 23:59 on the current date (fetch the MM/DD/YYYY from the current date as date components, then manually set the time to 23:59. That should work.

Second date Picker should show dates after the date selected in first date picker

I have two date pickers. In first I'm selecting a date, and I want second date picker to show the dates after that particular date. Previous dates should be disabled.
Use minimum date property of the date picker to disable the all date before the minimum date. The date picker would also allow you to define range as minimum and maximum date so that it can show the date from minimum to maximum date range and remaining all other date will be disabled in picker view.
swift 3
datePickerEndDate.minimumDate = datePickerStartDate.date

UIDatePicker customize available time intervals

Is it possible to set in UIDatePicker, date/time frames selectively? for example: show only Mondays from 8am to 4pm ?
Unfortunately, you cannot do this with standard UIDatePicker. Instead you should build your own custom date picker based on UIPickerView.

Resources