I'm trying to parse a date string into a Date
class. I'm using SwiftDate for this. But when I tried to parse it, it returned 1 day less than the value in the string. Here are some examples:
let birthString = "1996-10-08"
self.birthday = Date(birthString, format: "yyyy-MM-dd", region: Region.current)
//Result: self.birthday = 1996-10-07 17:00:00 UTC
let expiredString = "2019-09-30"
self.membershipExpiredDate = Date(expiredString, format: "yyyy-MM-dd", region: Region.current)
//Result: self.membershipExpiredDate = 2019-09-29 17:00:00 UTC
How do I fix this error? Thanks.