标签:nsstring nsdate ios开发 时间戳字符串转换
- (NSDate *)dateFromString:(NSString *)dateString{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
NSDate *destDate= [dateFormatter dateFromString:dateString];
return destDate;
}
- (NSString *)stringFromDate:(NSDate *)date{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//zzz表示时区,zzz可以删除,这样返回的日期字符将不包含时区信息。
[dateFormatter setDateFormat:@"MM-dd HH:mm"];
NSString *destDateString = [dateFormatter stringFromDate:date];
return destDateString;
}
-(NSString *)stringFromValue:(NSString *)value{
NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[value longLongValue]];
NSDateFormatter* formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"MM-dd HH:mm"];
NSString *date = [formatter stringFromDate:confromTimesp];
return date;
}
标签:nsstring nsdate ios开发 时间戳字符串转换
原文地址:http://blog.csdn.net/u011374880/article/details/41520227