How to get the inBetween days from fromdate and Todate in iOS swift?
Solution:
If you want to get the everyday from between tow days then follow the below code you can proceed with that.
You can give the Extension as date and get the function using the below code.
Code:
Class Viewcontroller:UIViewController {
}
If you want to get the everyday from between tow days then follow the below code you can proceed with that.
You can give the Extension as date and get the function using the below code.
Code:
Class Viewcontroller:UIViewController {
}
extension Date {
func inBetweenDates(fromDate:Date,toDate:Date) ->NSMutableArray {
let dateArray = NSMutableArray()
var from = fromDate
while from <= toDate {
var dates:Date = from
dates = truncateSecondsForDate(fromDate: dates)
dateArray.add(dates)
dates = from.addingTimeInterval(60*60*24*1)
from = dates
}
return dateArray
}
}
Comments
Post a Comment