1
votes

I am trying to check the expiration date of an auto-renewable receipt but in the sandbox, as soon as I purchase it and check the date it is 2 hours behind.

For example, if I purchase it at 5 pm, the expiration date will be

2:05 (two hours behind + 5 minutes)... 5 minutes is how long a 7-day subscription last in the sandbox.

The date on the receipt has this format:

"In App Subscription Expiration Date" = "2014-04-21 02:05:10 +0000";

Said that, shouldn't this hour on the receipt match the user time?

OK I can convert that to local time, but the big question here is should I always assume that the dates coming from Apple will come with +0000 = GMT?

1

1 Answers

1
votes

OK I can convert that to local time, but the big question here is should I always assume that the dates coming from Apple will come with +0000 = GMT?

No, but you should assume that Apple will provide you with a date in the same format (which includes the offset at the end). So, to convert it to local time, you would use something like this:

NSDate *expirationDate = [[NSDate alloc] initWithString:@"2014-04-21 02:05:10 +0000"]

And then to compare:

if ([expirationDate timeIntervalSinceNow] < 0) {
    //expired
}
else {
    //not expired
}

In all likelihood, Apple will probably always use GMT; however, if they feel it necessary to send the offset every time, you might as well check.