开发者

how to set the in setdateformat in datepicker coding not use in xib..... Im using DatePicker in Format @"yyyy-MM-dd-HH-mm-ss"

开发者 https://www.devze.com 2023-03-22 13:52 出处:网络
The output comes, for example: 17-10-1990 18:30:00 +0000. When we retrieve the value in NSDateFormatter the day is changed to 16-10-1990. No error comes.

The output comes, for example: 17-10-1990 18:30:00 +0000. When we retrieve the value in NSDateFormatter the day is changed to 16-10-1990. No error comes.

NSDateFormatter *sdayFormat = [[NSDateFormatter alloc] init];
[sdayFormat setDateF开发者_JS百科ormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *sdayString = [sdayFormat stringFromDate:datePicker.date];

please help me. I'm new in iphone developer.


to see how to set dateFormatter go to this link - NSDateFormatter and yyyy-MM-dd

and to see the list of all possible formats go to this link


Check this out!

    NSString *tDate = @"17-10-1990 18:30:00 +0000";

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

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

NSDate *fDate = [dateFormat dateFromString:tDate];

NSLog(@"Given date :%@ - Converted Date :%@",tDate,fDate);

use this link as reference for any date related operations

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

Hope this helps

0

精彩评论

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