---
title: Duration
framework: swift
role: symbol
role_heading: Structure
path: swift/duration
---

# Duration

A representation of high precision time.

## Declaration

```swift
@frozen struct Duration
```

## Overview

Overview Duration represents an elapsed time value with high precision in an integral form. It may be used for measurements of varying clock sources. In those cases it represents the elapsed time measured by that clock. Calculations using Duration may span from a negative value to a positive value and have a suitable range to at least cover attosecond scale for both small elapsed durations like sub-second precision to durations that span centuries. Typical construction of Duration values should be created via the static methods for specific time values.  var d: Duration = .seconds(3)  d += .milliseconds(33)  print(d) // 3.033 seconds Duration itself does not ferry any additional information other than the temporal measurement component; specifically leap seconds should be represented as an additional accessor since that is specific only to certain clock implementations.

## Topics

### Creating a duration

- [init(secondsComponent:attosecondsComponent:)](swift/duration/init(secondscomponent:attosecondscomponent:).md)
- [seconds(_:)](swift/duration/seconds(_:)-311cx.md)
- [seconds(_:)](swift/duration/seconds(_:)-5ifzr.md)
- [milliseconds(_:)](swift/duration/milliseconds(_:)-1w328.md)
- [milliseconds(_:)](swift/duration/milliseconds(_:)-7ledy.md)
- [microseconds(_:)](swift/duration/microseconds(_:)-1zzcc.md)
- [microseconds(_:)](swift/duration/microseconds(_:)-2majo.md)

### Accessing a duration’s components

- [components](swift/duration/components.md)

### Performing calculations on durations

- [*(_:_:)](swift/duration/*(_:_:)-3d469.md)
- [*=(_:_:)](swift/duration/*=(_:_:).md)
- [/(_:_:)](swift/duration/_(_:_:)-7fkmh.md)
- [/=(_:_:)](swift/duration/_=(_:_:)-10rgx.md)
- [/=(_:_:)](swift/duration/_=(_:_:)-1qfv3.md)

### Formatting a duration

- [formatted()](swift/duration/formatted().md)
- [formatted(_:)](swift/duration/formatted(_:).md)
- [Duration.TimeFormatStyle](swift/duration/timeformatstyle.md)
- [Duration.UnitsFormatStyle](swift/duration/unitsformatstyle.md)

### Initializers

- [init(attoseconds:)](swift/duration/init(attoseconds:).md)

### Instance Properties

- [attoseconds](swift/duration/attoseconds.md)

### Type Aliases

- [Duration.Specification](swift/duration/specification.md)
- [Duration.UnwrappedType](swift/duration/unwrappedtype.md)
- [Duration.ValueType](swift/duration/valuetype.md)

### Type Properties

- [defaultResolverSpecification](swift/duration/defaultresolverspecification.md)

### Type Methods

- [nanoseconds(_:)](swift/duration/nanoseconds(_:)-1cg32.md)
- [nanoseconds(_:)](swift/duration/nanoseconds(_:)-8nsaz.md)

### Default Implementations

- [AdditiveArithmetic Implementations](swift/duration/additivearithmetic-implementations.md)
- [AtomicRepresentable Implementations](swift/duration/atomicrepresentable-implementations.md)
- [Comparable Implementations](swift/duration/comparable-implementations.md)
- [CustomStringConvertible Implementations](swift/duration/customstringconvertible-implementations.md)
- [Decodable Implementations](swift/duration/decodable-implementations.md)
- [DurationProtocol Implementations](swift/duration/durationprotocol-implementations.md)
- [Encodable Implementations](swift/duration/encodable-implementations.md)
- [Equatable Implementations](swift/duration/equatable-implementations.md)
- [Hashable Implementations](swift/duration/hashable-implementations.md)

## Relationships

### Conforms To

- [AdditiveArithmetic](swift/additivearithmetic.md)
- [AtomicRepresentable](synchronization/atomicrepresentable.md)
- [BitwiseCopyable](swift/bitwisecopyable.md)
- [Comparable](swift/comparable.md)
- [Copyable](swift/copyable.md)
- [CustomLocalizedStringResourceConvertible](foundation/customlocalizedstringresourceconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Decodable](swift/decodable.md)
- [DisplayRepresentable](appintents/displayrepresentable.md)
- [DurationProtocol](swift/durationprotocol.md)
- [ElectricityInsightMeasure](energykit/electricityinsightmeasure.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [InstanceDisplayRepresentable](appintents/instancedisplayrepresentable.md)
- [IntentValueConvertible](appintents/intentvalueconvertible.md)
- [IntentValueExpressing](appintents/intentvalueexpressing.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [TypeDisplayRepresentable](appintents/typedisplayrepresentable.md)

## See Also

### Durations

- [DurationProtocol](swift/durationprotocol.md)
