Here's a code snippet that gets the date 5 days ago in Swift:
main.swift121 chars4 linesThe code above gets the current date using Date(), and then subtracts 5 days from it using calendar.date(byAdding:to:). The value parameter is set to -5 to subtract days, and the to parameter is set to today to subtract from the current date. The resulting date is stored in the fiveDaysAgo constant.
gistlibby LogSnag