I want to convert "2014-07-15 06:55:14.198000+00:00" this string date to NSDate in Swift.
相关问题
- how to split a list into a given number of sub-lis
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- JSP String formatting Truncate
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Selecting only the first few characters in a strin
- Enum with associated value conforming to CaseItera
For Swift 3
FOR SWIFT 3.1
NOTE: THIS WILL RETURN THE ORIGINAL STRING IF ERROR
If you're going to need to parse the string into a date often, you may want to move the functionality into an extension. I created a sharedCode.swift file and put my extensions there:
Then if you want to convert your string into a NSDate you can just write something like:
Swift 3,4:
2 useful conversions:
Usage: 1.
2.
Swift 4
Swift 3
I can do it with this code.