// custom use as from/to dates in a range // from date should be: current - 3 months // to date should be: current + 2 days // format should be yyyy-mm-dd myDateFormat.locale = Locale(identifier: "en_US_POSIX") myDateFormat.dateFormat = "y-MM-dd" if let fromDate = Calendar.current.date(byAdding: .month, value: -3, to: now) { let formattedFromDate = myDateFormat.string(from: fromDate) print("fromDate: \(formattedFromDate)") } if let toDate = Calendar.current.date(byAdding: .day, value: 2, to: now) { let formattedToDate = myDateFormat.string(from: toDate) print("toDate: \(formattedToDate)") } // fromDate: 2019-06-03 // toDate: 2019-09-05