swift get last year code example Example: swift 5 get current year let year = Calendar.current.component(.year, from: Date())