Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
プロジェクトで日付ピッカーを使用していますが、フォーマット属性を hh:mm として適用した後、選択した日付を 24 時間形式で取得しています。条件を使用して変換することで12時間形式の日付を取得できますが、 AM 、 PM を使用して日付ピッカーから12時間形式の時間を取得する直接的な方法を知りたいです。誰かがそれを行う最短の方法を知っているなら、あなたの答えで私を示してください. ありがとうございました!
このためのメソッドを作成しました。試してみてください
-(NSString*)getTimetoFill { NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; [outputFormatter setDateFormat:@"h:mm a"]; NSString *timetofill = [outputFormatter stringFromDate:datepicker.date]; return timetofill; }