I'm getting some start_times and end_times in the form of NSDecimalNumbers back from an API request.
I have successfully been able to convert these NSDecimalNumbers into NSDates, but the code is not taking time zones into account.
I need for it to use the timezone that is default on the device.
This should do what you need with current locale
double unixTimeStamp =1304245000;
NSTimeInterval _interval=unixTimeStamp;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
NSDateFormatter *formatter= [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateFormat:@"dd.MM.yyyy"];
NSString *dateString = [formatter stringFromDate:date];
Unix time doesn't have a time zone. it's defined in UTC as the number of seconds since midnight Jan 1 1970.
You should get the NSDates in the correct time zone by using
[NSDate dateWithTimeIntervalSince1970:myEpochTimestamp];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With