Creation date of the iOS keychain item varies with the region (or time format) change

Hi everyone,

My mobile app has a logic to store several items in the iOS keychain. While getting the creation date of the item, by using the kSecAttrCreationDate attribute and its description property, I notice that the value is susceptible to the region (or time format) change. Interestingly, it only happens to some regions, not all. For example, when I change the region to Australia or Ireland, the creation date value changes due to the date format change. I actually expect the value to remain constant, as the official documentation does not mention about the region (or time format) change. Is it the expected behaviour? Are there any other settings besides the region (or time format) change could cause this? Thank you.

Regards.

Are you certain the actual date is changing, or just the representation generated by the description property? The creation date attribute is a CFDate (equivalent to NSDate and Swift Date) so it has no concept of time zone or region or format. Do you have an example where description strings generated under different regions or time formats actually represent different creation dates for the same keychain item?

BTW, don’t use the description property in your user interface; it’s just for developer-facing things like debugging and logging. Make sure to use a suitable NSDateFormatter / DateFormatter whenever showing a date in the user interface.

Creation date of the iOS keychain item varies with the region (or time format) change
 
 
Q