ios - How do I url encode a date in objective-c -
i need url encode date parameter can send api.
for example if have date 2013-08-01 00:00:00 +0000
, need send through 2013-08-01+00%3a00%3a00+%2b0000
.
how can achieve it?
nsdate *mydate; // date should encoded nsdateformatter *df = [[nsdateformatter alloc] init]; df.dateformat = @"yyyy-mm-dd hh:mm:ss zzz"; nsstring *datestring = [df stringfromdate:mydate]; nsstring *encodeddate = [datestring stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];
Comments
Post a Comment