|
Hi! I'm using Contentful to fetch my app's content. They return the date as ISO 8601 string. I know how to convert a string into a date with DateFormatter or ISO8601DateFormatter, but when I fetch a date from API I have nil. String format example I need to convert:
Func I use to do it:
Please tell what I'm doing wrong and how to fix it? Thank you! Slava Ukraine! P.S. I fixed it.
|
|
Eugene is exploring ISO time. Good luck!
First, nice job finding a fix and reporting back. This will help others who might ask the same question! You might want to consider returning an optional
|
|
Additional observations:@twoStraws notes in one of his videos that working with Dates is hard. Very hard. I found a great resource, perhaps this will help you too? See-> Working with Dates In short, this video goes into great detail about parsing and formatting ISO dates and the tricky business of time zones. Once you have a nice Added bonus! Besides this excellent video, Ben created a terrific web site allowing you to interactively test different Swift date formats. See the results as you change format options! Cool. See-> NSDateFormatter.com Please report back if this helps! |
|
|
|
I can truly make the above code even simpler interior designer by omitting the requestLobbyInfo(from:) approach within the Player magnificence and, rather than checking if the contemporary player isn't the host and inquiring for data |
SPONSORED Transform your career with the iOS Lead Essentials. Unlock over 40 hours of expert training, mentorship, and community support to secure your place among the best devs. Click for early access to this limited offer and a FREE crash course.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.