how to get only years in swift 5 code example Example: swift 5 get current year let year = Calendar.current.component(.year, from: Date())