From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Time zones and date components

Time zones and date components

From the course: iOS Development Tips

Time zones and date components

- [Instructor] In a previous tip, you learned about the date, dateFormatter, and time interval classes. However, they don't help with specific times or localization of time zones. That's where the date components in time zone classes come into play. A date component provides a way to add components for a date. We'll add a few functions to get a date. Download and open the example playground. I set up a date and a dateFormatter. It's probably running by itself now and you can see on the bottom here that we've got a date. I'm gonna set this to manual just so it doesn't freak out as we're typing and I'm also gonna move over the viewers here so you can see what's going on in this panel. Then, go on down to where it says Type your code here on line 11 and I'll show you how to change time zones. There's a time zone property on date formatters which takes time zone object. Now, the simplest time zone object is the current time zone which gives you the time zone based on localization…

Contents