开发者

How to give correct input date format in iphone?

开发者 https://www.devze.com 2023-01-16 00:50 出处:网络
I donno to give the correct date format of the input date, so please give me to correct input date format.

I donno to give the correct date format of the input date, so please give me to correct input date format.

Here my sample code and the date formats.

        NSString *yourXMLDate = @"Thursday, September 9, 2010";

       NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];

       [inputFormatter setDateFormat:@"EEEE, MMMM dd, YYYY"]; // It doesnt work

  ---->[inputFormatter setDateFormat:@"EEEE, ????????????"];

        NSDate *inputDate = [inputFormatter dateFromString:yourXMLDate];

      NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];

    开发者_如何转开发   [outputFormatter setDateFormat:@"MM/dd"];

      NSString *outputDate = [outputFormatter stringFromDate:inputDate];

Thanks!


You can get the date formatters here

http://www.stepcase.com/blog/2008/12/02/format-string-for-the-iphone-nsdateformatter/

0

精彩评论

暂无评论...
验证码 换一张
取 消