I am working with Alamofire 4.0 and Swift 3.0
I am supposed to POST current date and time with timezone in my web service.
When I try to print in the console, I get correct current time, but when that data is pushed to the web service using Alamofire, the date and time gets changed/increased by 8 hours.
This is the code that I am trying. Please help me and make me understand when and why it is going wrong.
let now = NSDate();
let formatter = DateFormatter();
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss zzz";
let defaultTimeZoneStr = formatter.string(from: now as Date);
print(defaultTimeZoneStr)
Alamofire.request("http:********", method: .post, parameters: ["id": 1, "date" : defaultTimeZoneStr, "value": "null", "publisher": "Jack", "title": "Time Warner, "url": "internet/6/"], encoding: JSONEncoding.default).responseString
{
response in
print("Success: \(response.result.isSuccess)")
print("Response String: \(response.result.value)")
}
So in console, defaultTimeZoneStr will be my current time. But in the web service, it will be 8 hours late.
Please help.
Thank you.