开发者

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

开发者 https://www.devze.com 2023-04-07 02:44 出处:网络
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

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

精彩评论

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

关注公众号