Formatting and delta dates in Swift Nov 19, 2020 let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" let today = dateFormatter.string(from: Date()) let monthAgo = dateFormatter.string(from: NSCalendar.current.date(byAdding: .month, value: -1, to: NSDate() as Date)!)