I'm reading data from a XML file which has a UTC date looking like "2011-05-04T00:00:00", and a UTC epoch looking like 1352716800.
Parsing the UTC epoch to NSDate would probably be much safer than messing around with a complex date format. How would I parse the UTC epoch to NSDate? With NSDateFormatter and a special format for "UTC Epoch"?
I think that it is [[NSDate alloc] initWithTimeIntervalSince1970:epoch]
and a test seemed to work. But I am not sure if that's just correct by accident or if the "UTC epoch" is "Since 1970". The Apple Docs don't mention UTC Epoch.
YES, you are correct it is UTC Epoch. For Reference if "Epoch time is UTC" checkout this
In the case of the timestamp retrieved from Firebase (
kFirebaseServerValueTimestamp
), the epoch is expressed in milliseconds:In that case dividing by 1000 is needed if you use
initWithTimeIntervalSince1970
in iOS.You don't really need to parse the UTC epoch date. Instead you can more or less directly create an
NSDate
instance from it: