ios - Probelm in converting the date from String -
all,
in code getting string server value "06-27-2014", want convert other date format final result getting different. here code using.
nsstring* dateval = @"06-27-2014"; nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"mm-dd-yyyy"]; nstimezone *gmtzone = [nstimezone systemtimezone]; [dateformatter settimezone:gmtzone]; nsdate* adate = [dateformatter datefromstring:**dateval**]; getting adate **2014-01-26 18:36:00 +0000** here month changing first month 6th. nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdatestyle:nsdateformattershortstyle]; nsdate *thedateselected =adate; nsstring *thedate = [dateformat stringfromdate:thedateselected];
the final date getting 27/01/14 totally different can 1 suggest correct date format.
your date format wrong, should mm
month. mm
used minutes.
[dateformatter setdateformat:@"mm-dd-yyyy"];
should be
[dateformatter setdateformat:@"mm-dd-yyyy"];
Comments
Post a Comment