NSDate *date = [NSDate date]; //日期格式化类 NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; //y年 M月 d日 //m分 s秒 H(24)时 h(12)时 //2015-08-15 22:30:30 formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; NSString *str = [formatter stringFromDate:date]; NSString *time = @"2015/08/15 22:38"; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"yyyy/MM/dd HH:mm"; NSDate *date = [formatter dateFromString:time]; NSLog(@"%@", date); // 2015/08/15 22:38:00 (0时区时间)
时间: 2024-10-12 22:38:39