Separate Time from NSDate format like string?

后端 未结 1 2014
你的背包
你的背包 2021-01-28 06:24

I am having a Date String in this format \"2012-09-06 04:57:00.000\". I need to separate the time in that string in 04:57AM like that. help me out of this ?

相关标签:
1条回答
  • 2021-01-28 06:59
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"hh:mm:ss a"];
    NSString *timeStr =  [formatter stringFromDate:[NSDate date]];
    

    The above code is with ARC otherwise you need to release formatter like

    formatter release
    
    0 讨论(0)
提交回复
热议问题