Time zone for PHAsset creationDate

Dear Experts,

PHAsset.creationDate is an NSDate, which does not have a timezone associated with it, right?

Consider a photo viewer app. If I take a photo of the sunrise at 0600 local time while I am away, when I get home and view the photo in the app, I believe I want the timestamp shown with the photo to be 0600. Do you agree?

But NSDate is just a time-point, and I don't think Foundation (or anything else in iOS) has a type that combines a time-point with a time zone. Nor does PHAsset have any other useful attributes - unless I were to determine the time zone from the location!

Am I missing anything?

Post not yet marked as solved Up vote post of endecotp Down vote post of endecotp
938 views

Replies

NSDate is timezone-agnostic; it stores its dates relative to a fixed point. But NSDateFormatter is what you use to turn that into a date string, and that class has an NSTimeZone property.

  • Oh I see why you're asking here; you want the time to be displayed in the time zone where the photo was shot, not the current time zone. Many cameras don't even have a time zone setting, and the ones that do, the user probably is not remembering to set it. But in any case, you could look at location on PHAsset; there doesn't appear to be a built in way to translate that to an NSTimeZone but there are other conversations on the web about how to do that translation.

  • The problem with translating an asset’s location to TimeZone is iOS allows you to change the time zone via Adjust Date & Time (and there may not even be a location). It seems we need an API to expose its time zone.

  • I submitted FB13363638: PHAsset and PHContentEditingInput API to get creation date time zone

Add a Comment

AAaaarrgghh I wrote a long reply but this ******* useless ****** forum said "Unauthorized" when I pressed Submit and then Back shows an empty box. **** **** ****.

Summary:

Many cameras don't even have a time zone setting, and the ones that do, the user probably is not remembering to set it.

The iPhone does know the time zone.

Looking at the EXIF metadata for a photo from an iPhone, it does include the timezone.

But getting arbitrary EXIF fields using PHAsset is awkward. You have to fetch the entire image data, which is not great if they are e.g. iCLoud images and you just want to show thumbnails on a timeline.

  • You’re right that Photos knows the asset’s time zone. You can even change it in Adjust Date & Time. Where in the EXIF metadata is the time zone? I only see dates without time zone info.

Add a Comment

You’re exactly right. We need the associated time zone in order to display the correct date/time to the user. I submitted FB13363638: PHAsset and PHContentEditingInput API to get creation date time zone.

Note the time zone can be changed independently of the location via Adjust Date & Time, and photos don’t always have location anyways, so it’s not reliable to infer a time zone from its location.

  • Thanks for filing FB13363638.

Add a Comment