# \#date

**URL:** https://forums.swift.org/tag/date/241.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Swift-civil-time: PlainDate, PlainTime and PlainDateTime for Swift — no time zone, no Foundation](https://forums.swift.org/t/swift-civil-time-plaindate-plaintime-and-plaindatetime-for-swift-no-time-zone-no-foundation/90990)

<div class="topic-metadata">

**Author:** [@MacchaCat](https://forums.swift.org/u/MacchaCat)\
**Replies:** 5\
**Last updated:** [November 24, 2026, 2:12pm UTC](https://forums.swift.org/t/swift-civil-time-plaindate-plaintime-and-plaindatetime-for-swift-no-time-zone-no-foundation/90990 "2026-11-24T14:12:09Z")

</div>

Hi everyone, I'd like to share swift-civil-time, a small package of calendar-date and wall-clock-time types: import CivilTime let due = PlainDate(year: 2024, month: 1, day: 31)! due.adding(months: 1) // 2024-…

---

## [repeatedTimePolicy parameter of Calendar.nextDate not working when matching nanoseconds?](https://forums.swift.org/t/repeatedtimepolicy-parameter-of-calendar-nextdate-not-working-when-matching-nanoseconds/82300)

<div class="topic-metadata">

**Author:** [@Serika\_PHB](https://forums.swift.org/u/Serika_PHB)\
**Replies:** 1\
**Last updated:** [September 23, 2025, 10:54pm UTC](https://forums.swift.org/t/repeatedtimepolicy-parameter-of-calendar-nextdate-not-working-when-matching-nanoseconds/82300 "2025-09-23T22:54:57Z")

</div>

Because of the transition from PDT to PST, there will be two 1:30 in 2/11/2025, which can be distinguished with the repeatedTimePolicy parameter when calling Calendar.nextDate. var calendar = Calendar.init(identifier: .…

---

## [ISO8601DateFormatter fails to parse a valid ISO-8601 date](https://forums.swift.org/t/iso8601dateformatter-fails-to-parse-a-valid-iso-8601-date/22999)

<div class="topic-metadata">

**Author:** [@mohsen](https://forums.swift.org/u/mohsen)\
**Replies:** 28\
**Last updated:** [March 16, 2025, 7:20pm UTC](https://forums.swift.org/t/iso8601dateformatter-fails-to-parse-a-valid-iso-8601-date/22999 "2025-03-16T19:20:55Z")

</div>

Although, 2017-09-04T04:14:37.000Z is a valid ISO8601-formatted date, ISO8601DateFormatter cannot parse it. Seemingly, it happens when the string that represents an ISO8601-formatted date contains fractions of a second: …

---

## [Swift Foundation Date Representation](https://forums.swift.org/t/swift-foundation-date-representation/77954)

<div class="topic-metadata">

**Author:** [@CrownedPhoenix](https://forums.swift.org/u/CrownedPhoenix)\
**Replies:** 28\
**Last updated:** [March 3, 2025, 8:12pm UTC](https://forums.swift.org/t/swift-foundation-date-representation/77954 "2025-03-03T20:12:37Z")

</div>

Can/Should Foundation.Date use a fixed-point representation? Why I Care Since the release of Swift 6, I've started running into round-trip equality issues with Foundation.Date through sqlite-nio and postgres-nio. Speci…

---

## [Sorting of Date objects in ForEach loop](https://forums.swift.org/t/sorting-of-date-objects-in-foreach-loop/77592)

<div class="topic-metadata">

**Author:** [@anders7](https://forums.swift.org/u/anders7)\
**Replies:** 6\
**Last updated:** [February 2, 2025, 9:03am UTC](https://forums.swift.org/t/sorting-of-date-objects-in-foreach-loop/77592 "2025-02-02T09:03:08Z")

</div>

Hi all, I am a complete newbie here. Probably an easy fix but I cannot get this to work: I am trying to sort an array of Time objects so that in the UI the subject that happens first appears first. Here is the code: im…

---

## [Rounding error in milliseconds using ISO8601FormatStyle instead of ISO8601DateFormatter](https://forums.swift.org/t/rounding-error-in-milliseconds-using-iso8601formatstyle-instead-of-iso8601dateformatter/75206)

<div class="topic-metadata">

**Author:** [@jvdvleuten](https://forums.swift.org/u/jvdvleuten)\
**Replies:** 4\
**Last updated:** [October 11, 2024, 6:18pm UTC](https://forums.swift.org/t/rounding-error-in-milliseconds-using-iso8601formatstyle-instead-of-iso8601dateformatter/75206 "2024-10-11T18:18:34Z")

</div>

Hey there, I was using the new ISO8601FormatStyle and using the includingFractionalSeconds option for it. But when decoding and encoding an iso8601 string, I do get rounding errors in the millisecond part. I have setup…

---

## [Date.ParseStrategy(dateString:) overload?](https://forums.swift.org/t/date-parsestrategy-datestring-overload/70649)

<div class="topic-metadata">

**Author:** [@carlynorama](https://forums.swift.org/u/carlynorama)\
**Replies:** 3\
**Last updated:** [March 28, 2024, 2:03pm UTC](https://forums.swift.org/t/date-parsestrategy-datestring-overload/70649 "2024-03-28T14:03:06Z")

</div>

So I like a lot about how the new Date formatting options work, but sometimes I find the "format" part super verbose as I already have a whole cheat sheet of the styles I use and a String is a lot easier to store and pas…

---

## [\`Date.formatted(\_:)\` is returning a different string in Xcode 15](https://forums.swift.org/t/date-formatted-is-returning-a-different-string-in-xcode-15/67511)

<div class="topic-metadata">

**Author:** [@zkline101](https://forums.swift.org/u/zkline101)\
**Replies:** 9\
**Last updated:** [March 6, 2024, 4:39am UTC](https://forums.swift.org/t/date-formatted-is-returning-a-different-string-in-xcode-15/67511 "2024-03-06T04:39:46Z")

</div>

Hello! When using Date.formatted(\_:) in Xcode 15 vs Xcode 14.3.1, we are getting back a different string. Please see the image below to see the difference in the string. Before "PM" the single space is a different leng…

---

## [String Date to Date](https://forums.swift.org/t/string-date-to-date/62023)

<div class="topic-metadata">

**Author:** [@ashleydee1999](https://forums.swift.org/u/ashleydee1999)\
**Replies:** 2\
**Last updated:** [December 14, 2022, 1:07am UTC](https://forums.swift.org/t/string-date-to-date/62023 "2022-12-14T01:07:30Z")

</div>

Hi, I'm trying to convert my String Date to a Date, but it's displaying the wrong time let isoDate = "2022-12-14T04:30:00+05:30" let currentDateFormatter = DateFormatter() currentDateFormatter.dateFormat = "yyyy-MM-dd'…

---

## [How to parse dates formatted like "2020-09-16 23:44:47 +0200" for use in RegexBuilders](https://forums.swift.org/t/how-to-parse-dates-formatted-like-2020-09-16-2347-0200-for-use-in-regexbuilders/58243)

<div class="topic-metadata">

**Author:** [@dirk68](https://forums.swift.org/u/dirk68)\
**Replies:** 6\
**Last updated:** [June 20, 2022, 10:27am UTC](https://forums.swift.org/t/how-to-parse-dates-formatted-like-2020-09-16-2347-0200-for-use-in-regexbuilders/58243 "2022-06-20T10:27:18Z")

</div>

I, tried to parse a date in the following format and failed miserably: 2020-09-16 23:44:47 +0200 I wanted to parse a file containing dates in this format using the new RegexBuilders. I was not able to generate or pars…

---

## [JSON date format flavours support](https://forums.swift.org/t/json-date-format-flavours-support/56625)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 4\
**Last updated:** [April 11, 2022, 7:39am UTC](https://forums.swift.org/t/json-date-format-flavours-support/56625 "2022-04-11T07:39:18Z")

</div>

I have to work with backend that can return multiple flavours of iso8601 date format (and some other flavours as well). As far as I know iso8601 DateDecodingStrategy is very peculiar about format. Doing this custom strat…

---

## [Substraction between dates](https://forums.swift.org/t/substraction-between-dates/53681)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 1\
**Last updated:** [November 24, 2021, 4:44pm UTC](https://forums.swift.org/t/substraction-between-dates/53681 "2021-11-24T16:44:44Z")

</div>

I see there are static func + (lhs: Date, rhs: TimeInterval) -\> Date static func - (lhs: Date, rhs: TimeInterval) -\> Date But no static func - (lhs: Date, rhs: Date) -\> TimeInterval Is this asymmetry intentional? Or …

---

## [Explanation of Date object and timezones please](https://forums.swift.org/t/explanation-of-date-object-and-timezones-please/53220)

<div class="topic-metadata">

**Author:** [@jsoneaday](https://forums.swift.org/u/jsoneaday)\
**Replies:** 7\
**Last updated:** [November 2, 2021, 3:43pm UTC](https://forums.swift.org/t/explanation-of-date-object-and-timezones-please/53220 "2021-11-02T15:43:20Z")

</div>

I've read the Date struct docs but not sure I understand. It says that it's a specific time independent of a timezone. However when I take a Date() instance, and format it with the DateFormatter.timeZone as UTC the resu…

---

## [DateFormatter correct TimeZone set but output is in a bad time zone](https://forums.swift.org/t/dateformatter-correct-timezone-set-but-output-is-in-a-bad-time-zone/49071)

<div class="topic-metadata">

**Author:** [@kristofk](https://forums.swift.org/u/kristofk)\
**Replies:** 1\
**Last updated:** [May 31, 2021, 3:51pm UTC](https://forums.swift.org/t/dateformatter-correct-timezone-set-but-output-is-in-a-bad-time-zone/49071 "2021-05-31T15:51:54Z")

</div>

Hi, I'm trying to print out the time of a Date object but instead of printing "GMT+2" as it should, it prints "GMT+1" time. I am using the current time zone and locale. I expect the time string to be 3:00:27 PM GMT+2 bu…

---

## [Leaping Leap Seconds, Batman... 😔](https://forums.swift.org/t/leaping-leap-seconds-batman/48516)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 8\
**Last updated:** [May 19, 2021, 9:26am UTC](https://forums.swift.org/t/leaping-leap-seconds-batman/48516 "2021-05-19T09:26:03Z")

</div>

When I create a Date value from this string "2005-12-31T23:59:59Z" and then check its timeIntervalSinceReferenceDate value I find 157766399. The same process for "2006-01-01T00:00:00Z" yields 157766400. If I create a Dat…

---

## [How to Add millis to Date in Swift without loosing precession](https://forums.swift.org/t/how-to-add-millis-to-date-in-swift-without-loosing-precession/46874)

<div class="topic-metadata">

**Author:** [@igor](https://forums.swift.org/u/igor)\
**Replies:** 2\
**Last updated:** [March 24, 2021, 2:42pm UTC](https://forums.swift.org/t/how-to-add-millis-to-date-in-swift-without-loosing-precession/46874 "2021-03-24T14:42:05Z")

</div>

1. Date(timeIntervalSince1970: TimeInterval(millis) / 1000) It's easy to convert Date to millis, to add millis but the way back in all examples I came across like Date(timeIntervalSince1970: TimeInterval(millis) / 1000)…

---

## [Optional Date is not working?](https://forums.swift.org/t/optional-date-is-not-working/38648)

<div class="topic-metadata">

**Author:** [@nomunomu0504](https://forums.swift.org/u/nomunomu0504)\
**Replies:** 4\
**Last updated:** [July 22, 2020, 11:03am UTC](https://forums.swift.org/t/optional-date-is-not-working/38648 "2020-07-22T11:03:22Z")

</div>

Optional Date is not right working on my code. This is my code. extension String { func toDate(format: String = "yyyyMMddHHmmssSSS") -\> Date? { let dateFormatter = DateFormatter() dateFormatter.local…

---

## [Calendar/DateComponents: Trying to find the first date in a week](https://forums.swift.org/t/calendar-datecomponents-trying-to-find-the-first-date-in-a-week/35937)

<div class="topic-metadata">

**Author:** [@kai-vala](https://forums.swift.org/u/kai-vala)\
**Replies:** 2\
**Last updated:** [April 28, 2020, 1:48pm UTC](https://forums.swift.org/t/calendar-datecomponents-trying-to-find-the-first-date-in-a-week/35937 "2020-04-28T13:48:32Z")

</div>

Trying to find the fist date in the week of date 2020-04-17 (week 16). I'm expecting the first day in the week to be 04-13 (a Monday) since I've set the firstWeekday as 2. But the result date is 2020-04-12, which seems…

---

## [Introducing "Time"](https://forums.swift.org/t/introducing-time/34196)

<div class="topic-metadata">

**Author:** [@davedelong](https://forums.swift.org/u/davedelong)\
**Replies:** 49\
**Last updated:** [March 16, 2020, 11:17pm UTC](https://forums.swift.org/t/introducing-time/34196 "2020-03-16T23:17:33Z")

</div>

Today is Leap Day, so I'd like to introduce you to a new Swift package I've been working on for over 2 years: Time is a package that makes date and time calculations more expressive and safe in Swift. It's built on th…

---

## [Where was the review for this change?](https://forums.swift.org/t/where-was-the-review-for-this-change/26834)

<div class="topic-metadata">

**Author:** [@davedelong](https://forums.swift.org/u/davedelong)\
**Replies:** 4\
**Last updated:** [July 11, 2019, 2:00pm UTC](https://forums.swift.org/t/where-was-the-review-for-this-change/26834 "2019-07-11T14:00:04Z")

</div>

iOS 13 shows that Foundation.Date now conforms to the Strideable protocol. This proposal came up before (over a year ago!), but never went through review (that I'm aware of). :one: Did I miss this review? If so, can so…
