Here’s a sample list of what else can be done when messing with dates: All the above, including the conversions to and from strings, are subject for discussion in this tutorial.Through the next parts, you’ll see that is actually easy to do whatever you wish with dates, as long as you know what your tools are and how you should use them."en_US_POSIX" is also invariant in time (if the US, at some point in the future, changes the way it formats dates, "en_US" will change to reflect the new behaviour, but "en_US_POSIX" will not), and between machines ("en_US_POSIX" works the same on i OS as it does on OS X, and as it it does on other platforms).

Quite common is the reverse action as well; converting strings to date objects.

However, these are not the only tasks regarding dates.

The first important thing about this class is the fact that it can represent each date or time part as a single property, so each of it can be accessed directly and used in other tasks (such as calculations).

For example, the day and the month in a class is also quite useful when it’s necessary to calculate dates either in the future or in the past.

Even though you can download the provided playground file and open it in Xcode, I strongly suggest you to create a new Playground file and test every new code snippet presented in the following steps.

That way it’ll be easier for you to understand how each demonstrated aspect works, and moreover you’ll be able to modify it and see in real time how the results get changed depending on the modifications you perform.

Actually, the system needs to know what calendar to use prior to any conversion, so it’s possible to produce the proper results (don’t forget that there are different calendars all over the world, so the converted days, months, etc values can vary).

I’ll let you go and read more about calendars in the documentation link I provided you with in the introduction; all I have to say here is that for convenience we’ll use the , and it can be used for one single purpose: To take date and time units as input and produce human-readable, formatted strings of date as an output.

For your reference, I give you next a list of links with some important documentation.

Don’t forget to pay a visit in case you need more information on specific topics: aspects I want to deal with here.

It contains various methods for this job, and we’ll see a couple of them at the last part of the tutorial.