ios返回当前时间,精确到毫秒。

- (NSString *)getTimeNow  
{  
    NSString* date;  
     
    NSDateFormatter * formatter = [[NSDateFormatter alloc ] init];  
    //[formatter setDateFormat:@"YYYY.MM.dd.hh.mm.ss"];  
    [formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss:SSS"];  
    date = [formatter stringFromDate:[NSDate date]];  
    timeNow = [[NSString alloc] initWithFormat:@"%@", date];  
    NSLog(@"%@", timeNow);  
    return timeNow;  
}  

你可能感兴趣的:(ios返回当前时间,精确到毫秒。)