nsdate - iPhone NSDateFormatter US region style -
i working on writing iphone app. want current date following format.
tur, 18 apr 2013 09:20:47
i tried following code.
nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter settimezone:[nstimezone timezonewithname:@"gmt"]]; [dateformatter setdateformat:@"e, dd mmm yyyy hh:mm:ss"]; nsstring *formatteddate = [dateformatter stringfromdate:[nsdate date]]; [dateformatter release];
the problem iphone region not us, following string.
木, 18 4月 2013 09:20:47
how can resolve this?
set locale
property of date in format
dateformatter.locale = [[[nslocale alloc] initwithlocaleidentifier:@"en_us"] autorelease];
or
[dateformatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us"]];
Comments
Post a Comment