Patrick Jollain
Patrick Jollain

Reputation: 65

iOS 10: issue with timezone when dealing with dates from HealthKit

I am writing an app with iOS 10 that extract information from HealthKit, getting the samples from BodyMass, from which I extract the date of the measure and the weight. In the simulator, I have entered some values:
Date: 7 Sep, 16:52 - Weight: 92,3
Date: 8 Sep, 16:52 - Weight: 92,1

When the application reads the first date from HKQuantitySample, I get: 2016-09-07 14:52:00 +0000

I have a 2 hours difference between the date as seen from the standard health application, and the date retrieved by my app, this difference corresponding to the GMT+2 of my current location.

How should I proceed to get the date as it can be seen from the health app?

Upvotes: 2

Views: 689

Answers (1)

Estel
Estel

Reputation: 2204

You should look at retrieving the HKMetadataKeyTimeZone metadata property. Good clients should be storing the timezone information in this key so you can present the correct time back to your user.

Upvotes: 2

Related Questions