ios - How to show timezone abbreviation with the date -


i getting time in utc , want append timezone abbreviation it. have below code timezone abbreviation giving gmt +5.30. want ist.

for america giving edt, need timezones give 3 letter abbreviation.

is possible?

please check below code:

nsdateformatter* dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"yyyy-mm-dd't'hh:mm:ss.sssz"]; nsdate* sourcedate = [dateformatter datefromstring:@"2015-03-16t13:08:17.989z"]; nstimezone* destinationtimezone = [nstimezone defaulttimezone]; nsstring *str =[destinationtimezone abbreviation];  nsdateformatter* dateformat = [[nsdateformatter alloc] init];  [dateformat setdateformat:@"mmmm dd yyyy, hh:mm "]; nsstring* localtime = [dateformat stringfromdate:sourcedate]; nsstring* str1 = [nsstring stringwithformat:@"%@, %@",localtime, str]; nslog(@"localtime:%@", str1); 

the output is:

localtime:march 16 2015, 18:38 , gmt+5:30

i need

localtime:march 16 2015, 18:38 , ist

please help!

you can set time zone date :

[dateformat settimezone:desiredtimezone]; 

then format using date formatter :

nsdateformatter *formatter = [nsdateformatter new]; formatter.dateformat = @"dd mmm @ hh:mm z"; 

abow code z property according time zone in 03 letter format.

for more details click here


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -