NSString表示的时间转为time_t

 1 time_t convertTimeStamp(NSString *stringTime)
2 {
3 time_t createdAt;
4 struct tm created;
5 time_t now;
6 time(&now);
7
8 if (stringTime) {
9 if (strptime([stringTime UTF8String], "%a %b %d %H:%M:%S %z %Y", &created) == NULL) {
10 strptime([stringTime UTF8String], "%a, %d %b %Y %H:%M:%S %z", &created);
11 }
12 createdAt = mktime(&created);
13 }
14 return createdAt;
15 }
原文地址:https://www.cnblogs.com/woainilsr/p/2368059.html