I am using Core-Datato store date-time object.
Eg. 2015-07-28T07:16:52+0000 this is date in ISO format in GMT timezone.
But when I save this date in database
NSString* dateString=@"2015-07-28T07:16:52+0000";
NSDateFormatter* dateTimeformatter=[[NSDateFormatter alloc] init];
[dateTimeformatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
[dateTimeformatter dateFromString:dateString];
the resulting date which I see in database is 2015-07-28 12:46:52
which is in IST according to my device's timezone
I tried to set timezone as well in dateFormatter but again the same response
NSString* dateString=@"2015-07-28T07:16:52+0000";
NSDateFormatter* dateTimeformatter=[[NSDateFormatter alloc] init];
[dateTimeformatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
[dateTimeformatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
[dateTimeformatter dateFromString:dateString];
Even when I save the [NSDate date] directly in database , it saves the converted date according to device's timezone.
Why Core-data is not taking the timezone of NSDateFormatter into account?
Can anyone tell me how can I save the date in GMT in database irrespective of my device's timezone?