Search This Blog

Thursday, 10 April 2014

Check Date Format in iPhone

This method is useful to check which date formate is selected in iphone etither 24 hours or 12 hours

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];


Bool HourFormate24 = (amRange.location == NSNotFound && pmRange.location == NSNotFound);

No comments:

Post a Comment