0

For iOS, how does one calculate the number of days between two dates generated by two different date pickers?

BKO
  • 1
  • 1
  • 1
    UIDatePicker has a date parameter. Take the date from each, and refer to https://stackoverflow.com/questions/24723431/swift-days-between-two-nsdates for the rest. – kid_x Jan 29 '19 at 22:41
  • I tried to use this method, but I was unable to get it to work: var days = Calendar.current.dateComponents(components: Set, from: Date, to: Date). Thanks for the suggestion. I'll give it a try. – BKO Jan 29 '19 at 23:31
  • If it's still not working after, post a snippet of your attempt so we can debug it. It's hard to understand the context without any code. – kid_x Jan 29 '19 at 23:42
  • Thanks so much. It now works. I tried to post a snippet, but unsure how. Need to learn. – BKO Jan 30 '19 at 00:25
  • Possible duplicate of [How can I calculate the difference between two dates?](https://stackoverflow.com/questions/4371757/how-can-i-calculate-the-difference-between-two-dates) – Rocky Jan 30 '19 at 02:29

0 Answers0