Pregunta

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)

¿Fue útil?

Solución

I solved my own problem:

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setCalendar:gregorianCalendar];
[formatter setDateStyle:NSDateFormatterFullStyle];
[formatter setTimeStyle:NSDateFormatterFullStyle];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top