I am using following code to parse the time stamp value. But when I convert it to date it is giving correct value (03-08-2021) but then I tried to convert this date to string to fulfil my requirements.
But that string resulting a wrong value 03-07-2021. Following is the code I am using.
let epocTime = TimeInterval(1615161600000/1000)
let date = Date(timeIntervalSince1970: epocTime)
print(date)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
dateFormatter.timeZone = .current
dateFormatter.locale = .current
let dateString = dateFormatter.string(from: date)
print(dateString)