将字符串转换为 NSDate
如何在 iOS 上将字符串转换为 NSDate
?
How is it possible to convert a string to an NSDate
on iOS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在 iOS 上将字符串转换为 NSDate
?
How is it possible to convert a string to an NSDate
on iOS?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
希望这会对您有所帮助。
Hope this will help you.
您需要查看 NSDateFormatter。确定日期字符串的格式,然后使用 dateFromString: 将该字符串转换为 NSDate 对象。
You'll want to take a look at NSDateFormatter. Determine the format of the date string and then use
dateFromString:
to convert the string to an NSDate object.我的 Swift 工作版本
My working version in Swift
简单的方法,即使您有sqlite DB:
此示例的输出:
2015 年 8 月 3 日下午 12:27:50
A simple approach even if you have sqlite DB:
The output for this example:
Aug 3, 2015, 12:27:50 PM