Reputation: 43
I set date format to @"HH:mm"
This works if the hour is double digits. but if the hour is a single digit, I need to set format to @"H:mm"
so it displays 9:00
, rather than 09:00
. How can I parse NSDate or automatically detect which format I need to use?
Upvotes: 1
Views: 1954
Reputation: 318774
Just use H:m
and it will parse time strings such as 9:1
, 09:05
, 12:1
, or 12:07
, etc.
If you want to create a time string from an NSDate
then use H:mm
. This will give 9:15
or 12:15
, etc.
Upvotes: 6