I want to get a temporary string like "10:00 PM", and for this I use NSDateFormatterShortStyle. However, when the system is configured to use the 24-hour format, I got "22:00".
In addition, I want to get a localized time string. For example, in Chinese, I want to get "δΈε 10:00" instead of "10:00 PM". Therefore, I must use [NSLocale currentLocale] and cannot use the en_US_POSIX locale.
Please help me get a localized 12-hour time format string.
I need not only the hour part, but also the am / pm part. In addition, the am / pm part may be located before the hour / minute part or after the hour / minute part, depending on the locale. In the same way as the system display time. When the system is configured to use the 12-hour format, itβs easy. But when the system uses a 24-hour format, I just can't get a localized 12-hour time format string.
source
share