I have set datePickerMode: .time and gave max and min hour. But I want to disable minutes selection but didn't find any solution. I can give minutesInterval but I just want to show or choose only 00 for minutes. User must select only hour.
Thanks for your help
What if you set the minuteInterval property of the date picker to 60?
If that doesn't work, and the only thing you're using the date picker to collect is hours, why not create a regular UIPickerView with hour values from 12 AM to 11 PM? (Or 0 AM to 23 PM, if you're using 24 hour time.)
Related
I have two UIDatePickers. startDatePicker is to choose a start date and endDatePicker is to choose an end date. It should be something like
START: 2015/06/25 11:00
END: 2015/07/06 13:00
->Time Interval: 12 days 2 hours = 1044000 seconds
And the 1044000 seconds is what I want to get here. Just I am not sure how.
I am guessing maybe I can use
startDatePicker.date.timeIntervalSinceDate(endDatePicker.date)
to get the value? If so, what is the necessary settings for the two UIDatePickers?
Or maybe there are other ways to do that? Thanks in advance.
I want to add event in device calendar on monthly which is working fine to me. But the problem is occurred in second condition. Suppose we add one event on 31st of each month and if 31 is not exist in that month then add on last day of that month such 30 April, 28 Feb.
Any suggestion to solve that condition???
Thanks
I'm trying to have a UIDatePicker to present only the date, month and year to the user. I want to avoid presenting them with the hours, minutes and seconds like it comes by default. I've tried looking for something that might help but can only find solutions that aren't explained clearly in Objective-C, however I'm coding in Swift. Any ideas? Thanks in advance!
you need to chose the mode of the date picker
#IBOutlet weak var myDatePicker: UIDatePicker!
override func viewDidLoad() {
super.viewDidLoad()
myDatePicker.datePickerMode = .date // or .Date (Swift 2.x)
}
date picker options .
Declaration SWIFT
var datePickerMode: UIDatePickerMode
Discussion The
value of this property indicates the mode of a date picker. It
determines whether the date picker allows selection of a date, a time,
both date and time, or a countdown time. The default mode is
UIDatePickerModeDateAndTime. See Date Picker Mode for a list of mode
constants.
UIDatePickerMode
The mode of the date picker.
Declaration Constants
Time
The date picker displays hours, minutes, and (optionally) an AM/PM designation. The exact items shown and their order depend upon the locale set. An example of this mode is [ 6 | 53 | PM ].
Available in iOS 2.0 and later.
Date
The date picker displays months, days of the month, and years. The exact order of these items depends on the locale setting. An example of this mode is [ November | 15 | 2007 ].
Available in iOS 2.0 and later.
DateAndTime
The date picker displays dates (as unified day of the week, month, and day of the month values) plus hours, minutes, and (optionally) an AM/PM designation. The exact order and format of these items depends on the locale set. An example of this mode is [ Wed Nov 15 | 6 | 53 | PM ].
Available in iOS 2.0 and later.
CountDownTimer
The date picker displays hour and minute values, for example [ 1 | 53 ]. The application must set a timer to fire at the proper interval and set the date picker as the seconds tick down.
Available in iOS 2.0 and later.
If you're using storyboards just change mode to "date" in the Attributes inspector.
YourPickerView.datePickerMode=UIDatePickerModeDate;
I wonder if there is a way to custom a datepicker's time range?
How can I remove minute column and leave only 9 and 5 in hour column? is that possible?
Maybe you should considere to use this cocoapod:
https://www.cocoacontrols.com/controls/dvdatepickertableviewcell
or this webpage:
http://blog.deeplink.me/post/81386967477/how-to-easily-customize-uidatepicker-for-ios
and try to custom it as you want.
For UIDatepicker it is not possible to remove the minutes column or only to show 9 and 5 hour in hour column.
UIDatePickerModeDateAndTime:
The date picker displays dates (as unified day of the week, month, and day of the month values) plus hours, minutes, and (optionally) an AM/PM designation. The exact order and format of these items depends on the locale set. An example of this mode is [ Wed Nov 15 | 6 | 53 | PM ].
You need to use custom datepicker for that,you may consider to look at this link for custom picker https://github.com/mwermuth/MWDatePicker
for MWDatePicker first date were invisible but changing the font color like this [datePicker setFontColor:[UIColor blueColor]]; in viewdidLoad in MWViewController.m make them visible.And then modifying the method fillWithCalendar in MWDatePicker.m like this
- (void)fillWithCalendar{
minutes = #[#""];
hours = #[#"05",#"09"];
////others coding
}
i think would give you desired output.
I need a UIDatePicker or UIPickerView with the following date format:
yyyy-MM-dd HH-mm
Do I have to create it ? or is there some pickerStyle or pickerMode that implements it?
You can do this simply by using a UIDatePicker and then set the pickerMode for it. Since, you need both Date as well as Time, all you have to do is set the mode to UIDatePickerModeDateAndTime
UIDatePicker *datePicker;
timePick.datePickerMode =UIDatePickerModeDateAndTime;
The following is provided in the Apple documentation for the above mode-
The date picker displays dates (as unified day of the week, month, and
day of the month values) plus hours, minutes, and (optionally) an
AM/PM designation. The exact order and format of these items depends
on the locale set. An example of this mode is [ Wed Nov 15 | 6 | 53 | PM ].
EDIT:
In your case, I think the only option you have is to implement two UIDatePickers, one with mode set as UIDatePickerModeDate and another with UIDatePickerModeTime. Then, you can concat them both into an NSDate.
Hope this helps!!