使用NSDateFormatter格式化输出时间

    NSDate *date = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *current = [dateformatter stringFromDate:date];
    NSLog(@"current time is : %@", current);

你可能感兴趣的:(ios,NSDate,nsdateformatter)