Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSDate from NSString when time is in 24 hr format

I have a string of the format Jan 25, 2011 3:17 AM. I need to convert it to NSDate. I used NSDateFormatter with format @"MMM d, yyyy h:mm a". It Works well if iphone time is in 12 hr format, but returns nil if time is in 24 hr format. Can any one help me with this????

like image 204
PgmFreek Avatar asked Jan 21 '23 15:01

PgmFreek


1 Answers

Capital H is used for 24 hour format. Don't 24 hour times usually exclude the AM/PM part? If so, your format string should be: @"MMM d yyyy H:mm".

Here's a reference for Unicode date format strings.

like image 95
pwc Avatar answered Jan 31 '23 06:01

pwc