In my sqlite db I have a NSDate field and I create a image file with a unique name using this code and based on that date I load the image.
NSDateFormatter *digitsOnlyDateFormatter = [[NSDateFormatter alloc] init];
[digitsOnlyDateFormatter setDateFormat:@"yyyyMMddHHmmss"];
NSString *imageDateString = [digitsOnlyDateFormatter stringFromDate:[self imageDate]];
If I change the time zone from iphone settings and I add a new record in db, other images saved with another time zone could not be loaded.
I think there is a problem with conversion.
Can someone help me?
Part of
NSDateFormatters format can be overridden by user settings: specifically the choice of AM/PM versus 24-hour time.You can solve this by setting the formatter’s locale. (Note: this is something you should only do in situations like this to create strings that need to be consistent across locales and won’t be displayed to the user).
P.S. if you want the string to be made relative to the same timezone as well, you should also set the formatter’s timezone: