<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/JSONEncoder/DateEncodingStrategy-swift.enum",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11JSONEncoderC20DateEncodingStrategyO"
  },
  "title" : "JSONEncoder.DateEncodingStrategy"
}
-->

# JSONEncoder.DateEncodingStrategy

The formatting strategies available for formatting dates when encoding a date as JSON.

```
enum DateEncodingStrategy
```

## Topics

### Default Formats

[`JSONEncoder.DateEncodingStrategy.deferredToDate`](/documentation/Foundation/JSONEncoder/DateEncodingStrategy-swift.enum/deferredToDate)

The strategy that uses formatting from the Date structure.

### Standard Formats

[`JSONEncoder.DateEncodingStrategy.iso8601`](/documentation/Foundation/JSONEncoder/DateEncodingStrategy-swift.enum/iso8601)

The strategy that formats dates according to the ISO 8601 and RFC 3339 standards.

### Custom Formats

[`JSONEncoder.DateEncodingStrategy.formatted(_:)`](/documentation/Foundation/JSONEncoder/DateEncodingStrategy-swift.enum/formatted(_:))

The strategy that defers formatting settings to a supplied date formatter.

[`JSONEncoder.DateEncodingStrategy.custom(_:)`](/documentation/Foundation/JSONEncoder/DateEncodingStrategy-swift.enum/custom(_:))

The strategy that formats custom dates by calling a user-defined function.

### Epoch Formats

[`JSONEncoder.DateEncodingStrategy.millisecondsSince1970`](/documentation/Foundation/JSONEncoder/DateEncodingStrategy-swift.enum/millisecondsSince1970)

The strategy that encodes dates in terms of milliseconds since midnight UTC on January 1, 1970.

[`JSONEncoder.DateEncodingStrategy.secondsSince1970`](/documentation/Foundation/JSONEncoder/DateEncodingStrategy-swift.enum/secondsSince1970)

The strategy that encodes dates in terms of seconds since midnight UTC on January 1, 1970.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)