<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "StoreKit",
  "identifier" : "/documentation/StoreKit/Product/PurchaseOption/purchaseDate(_:renewalBehavior:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "StoreKit"
    ],
    "preciseIdentifier" : "s:8StoreKit7ProductV14PurchaseOptionV0aB4TestE12purchaseDate_15renewalBehaviorAE10Foundation0H0V_AeFE019SubscriptionRenewalJ0OtFZ"
  },
  "title" : "purchaseDate(_:renewalBehavior:)"
}
-->

# purchaseDate(_:renewalBehavior:)

Sets the purchase date for the transaction in the testing environment, and indicates the renewal behavior for an auto-renewable subscription.

```
static func purchaseDate(_ date: Date, renewalBehavior: Product.PurchaseOption.SubscriptionRenewalBehavior = .renewUntilNow) -> Product.PurchaseOption
```

## Parameters

`date`

The purchase date for the transaction. Specify a date in the past or the current moment. Dates in the future aren’t valid.

`renewalBehavior`

The renewal behavior for the auto-renewable subscription in this transaction, whether it renews continuously from the purchase date, or it cancels after the first period. By default, the subscription renews.

## Discussion

Use this purchase option when you test your app in Xcode using <doc://com.apple.documentation/documentation/StoreKitTest> and call <doc://com.apple.documentation/documentation/StoreKitTest/SKTestSession/buyProduct(identifier:options:)>.

Use this purchase option to create useful transactions for your test cases. For example, use a date in the past with the default `renewalBehavior` to generate a full history of subscription renewals to test. Or, use a date in the past with the [`Product.PurchaseOption.SubscriptionRenewalBehavior.cancelImmediately`](/documentation/StoreKit/Product/PurchaseOption/SubscriptionRenewalBehavior/cancelImmediately) behavior to simulate an account of a customer who canceled their subscription.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)