开发者

How to set the Dateformat for current date in iphone application?

I am developing one application. In that i write the below code for setting开发者_C百科 the DateFormat for current date. But it is working upto 9th month only. From 10th month onwards it gives the nil value. So please tell me how to solve this one. My code is as below:

 NSDate *datestr = clInfo.cldrinfodate;
 NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init];
 [dateFormat1 setDateFormat:@"MM/dd/yyyy hh:mma"];
 NSString *date1 = [dateFormat1 stringFromDate:datestr];


you can try this one.

     NSDate * mCurrentDate = [NSDate date];

    NSLog(@"current date=%@",mCurrentDate);
    NSDateFormatter *dt=[[NSDateFormatter alloc] init];

    [dt setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

    NSString *st=[dt stringFromDate:mCurrentDate];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜