문제

Using this code

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm"];

having defaults of '2014' on my datepicker, Using Thai calendar gives me headache for displaying a year of 2557 (which is of course in Thai locale) to its year picker on the UIdatepicker. yes that is correct - but I want to get it's value in gregorian calendar format so I could save it on the database without any worries. can I do that on my NSDateFormatter? (also including hours, minutes, and days)

도움이 되었습니까?

해결책

I solved my own problem:

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setCalendar:gregorianCalendar];
[formatter setDateStyle:NSDateFormatterFullStyle];
[formatter setTimeStyle:NSDateFormatterFullStyle];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top