1

NSDateFormatter を使用して 2013-02-08T10:50:00.000 のような NSString を 10:50AM に変換しようとしています。 (2013-02-08T15:00:00.000) 何かアイデアはありますか?

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"HH-mm"];
    NSString *datelocalformat= [dateFormatter stringFromDate:DepartTimeString];
4

1 に答える 1

0
NSDate *today = [NSDate date];//get today's date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
 NSString *dateString = [dateFormatter stringFromDate:today];
[dateFormatter release];

// Get time - display in 12HR
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
[timeFormatter setTimeStyle:NSDateFormatterLongStyle];
NSString *timeString = [timeFormatter stringFromDate:today];
[timeFormatter release];
于 2013-02-10T23:20:36.980 に答える