<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/SystemFormatStyle/Stopwatch",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17SystemFormatStyleO9StopwatchV"
  },
  "title" : "SystemFormatStyle.Stopwatch"
}
-->

# SystemFormatStyle.Stopwatch

A format style that displays elapsed time as a precision
stopwatch counting up from zero.

```
struct Stopwatch
```

## Overview

`Stopwatch` produces output in a time-pattern format that
includes hundredths of a second by default, making it suitable
for use cases such as athletic timing where sub-second
precision matters.

```swift
let startDate = Date.now
Text(.currentDate, format: .stopwatch(startingAt: startDate))
// Output: "00:05.23" (after 5.23 seconds)
```

### Output format progression

The stopwatch automatically adds an hours field when the
elapsed time reaches one hour:

|Elapsed       |Output       |
|--------------|-------------|
|Under 1 min   |`00:05.23`   |
|Under 1 hour  |`45:30.12`   |
|1 hour or more|`01:00:00.00`|
|Over 25 hours |`25:01:01.00`|

### Adjusting precision

Control the displayed precision with the `maxPrecision`
parameter:

```swift
// Whole-second precision (no fractional digits)
.stopwatch(startingAt: start, maxPrecision: .seconds(1))
// Output: "01:23"

// Tenth-of-a-second precision (one fractional digit)
.stopwatch(startingAt: start, maxPrecision: .milliseconds(100))
// Output: "01:23.4"

// Minute-only precision
.stopwatch(startingAt: start, maxPrecision: .seconds(60))
// Output: "1 hour" or "23 minutes"
```

### Controlling field count

The `maxFieldCount` parameter limits how many fields appear:

```swift
// At 1 hour, 23 minutes, 45.67 seconds elapsed:
// maxFieldCount: 4 (default): "01:23:45.67"
// maxFieldCount: 3: "01:23:45"
// maxFieldCount: 2: "1:23" (hours and minutes only)
```

## Relationships

### Conforms To

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

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

[`DiscreteFormatStyle`](/documentation/Foundation/DiscreteFormatStyle)

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

[`FormatStyle`](/documentation/Foundation/FormatStyle)

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

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

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

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

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

---

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)