When it comes to dealing with date, it is never simple.
The Apple programming guide has a chapter on
NSDateFormatter, but it is not clear enough.
Refer to unicode.org for the date format pattern. It is so important a document that you should bookmark it!
To escape in the pattern string, you can enclose with single quote.
For example, to escape the character “T”, you use
'T'HH:mm:ss. The pattern produces eg. T09:30:00
‘Z’ is for Zulu Time
Another common format is
Z at the end refers to Zulu time, which is also GMT and UTC. It is the RFC 3339 format.
Zulu sounds like zero - the zero hours.
NSDate don’t have a time zone.
It is basically an invariant time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001).
The most widely used calendar is gregorian, but there are others.
Print out all the supported time zone with:
NSLog(@"%@", [NSTimeZone knownTimeZoneNames]);
If you know a name, you can init a timezone easily:
You can also refer to wiki for a list of the timezone names.
3rd Party Libraries
In JS world, moment.js is a very popular library to deal with date, time and relative moments.
YLMoment is a smilar one in Objective-C.