-
(NSString*)getCurrentTimesWithFormat:(NSString *)format{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
// ----------設(shè)置你想要的格式,hh與HH的區(qū)別:分別表示12小時(shí)制,24小時(shí)制
[formatter setDateFormat:format];
//現(xiàn)在時(shí)間,你可以輸出來看下是什么格式
NSDate *datenow = [NSDate date];
//----------將nsdate按formatter格式轉(zhuǎn)成nsstring
NSString *currentTimeString = [formatter stringFromDate:datenow];
NSLog(@"currentTimeString = %@",currentTimeString);
return currentTimeString;
}