Search code examples
iosobjective-ccocoa-touchnsdateformatter

Remove 0 at beginning of formatted time


I have an NSDate formatted with NSDateFormatter as "hh:mm:ss". Everything displays properly except when the hour is one digit (e.g. 3:00) it would display 03:00. How would I get rid of that 0 so it would display 3:00?


Solution

  • If you use 1 h instead of two you will not get the leading 0.

    h:mm:ss