Chetan Purohit Chetan Purohit - 2 years ago 798
iOS Question

How to accept only Month and Year using DatePicker in iOS

I am building an app using swift and in that app there is one field for accepting expiry date for Debit card for payment purpose. How can I accept only month and year by using DatePicker in Swift.

If it is not possible using datepicker then please suggest any another way.

Thank you in advance.

Answer Source



yourDatepicker.datePickerMode = UIDatePickerModeDate;


 yourDatepicker.datePickerMode = UIDatePickerMode.Date

the another modes are

  • UIDatePickerModeTime,
  • UIDatePickerModeDate,
  • UIDatePickerModeDateAndTime,
  • UIDatePickerModeCountDownTimer


the above method not working well, then check this link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download