扫码关注官方订阅号
新手,刚学iOS,小问题比较多。 现在获取到一个时间为 1990-05-04, 这样格式的 请问怎么将这个时间转换成时间戳,因为Api的接口是要时间戳格式的?求助
1990-05-04
人生最曼妙的风景,竟是内心的淡定与从容!
如果你用的是 Objective-C 可以这样写:
Objective-C
objectivecNSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"YYYY-MM-dd"; NSDate *date = [formatter dateFromString:@"1990-05-04"]; long timeSp = (long)[date timeIntervalSince1970]; //时间戳
objectivec
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"YYYY-MM-dd"; NSDate *date = [formatter dateFromString:@"1990-05-04"]; long timeSp = (long)[date timeIntervalSince1970]; //时间戳
swift 类似
swift
Swift : NSDate().timeIntervalSince1970
Objective-C : [[NSDate date] timeIntervalSince1970]
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
如果你用的是
Objective-C可以这样写:swift类似Swift : NSDate().timeIntervalSince1970
Objective-C : [[NSDate date] timeIntervalSince1970]