标签:时间 nsstring转为时间戳
NSString *dateStr=@"2012-05-17 11:23:23"; NSLog(@"dateStr=%@",dateStr); NSDateFormatter *format=[[NSDateFormatter alloc] init]; [format setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSDate *fromdate=[format dateFromString:dateStr]; NSTimeZone *fromzone = [NSTimeZone systemTimeZone]; NSInteger frominterval = [fromzone secondsFromGMTForDate: fromdate]; NSDate *fromDate = [fromdate dateByAddingTimeInterval: frominterval]; NSLog(@"fromdate=%@",fromDate); CGFloat timeSp = [fromDate timeIntervalSince1970]; NSLog(@"timeSp:%f",timeSp);
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:时间 nsstring转为时间戳
原文地址:http://blog.csdn.net/mr_banma/article/details/47747877