I am getting date in the form of milliseconds from URL Request
It is is this form in JSON Dictionary like this:
AllocationDate = "/Date(1514485800000)/";
I am using the following code to convert it to yyyy-MM-dd format:
let data4 = data_object1["AllocationDate"] as! String
let start = data4.index(data4.startIndex, offsetBy: 6)
let end = data4.index(data4.endIndex, offsetBy: -2)
let range = start..<end
let milliseconds = Double(data4.substring(with: range))
let date = Date(timeIntervalSince1970: (milliseconds!/1000))
let dateString = String(describing: date)
print(dateString)
Now, it prints 2017-12-28 18:30:00 +0000, whereas the real date is 2017-12-29.
Check it on:https://www.timecalculator.net/milliseconds-to-date
So every date is getting converted to previous date of the actual date.
Please help me.If i'm making some mistake in my code or something. Thank You!