We really ♥ Swift and we think that dates and timezones management should be painless: this is the reason we made SwiftDate, probably the best way to manage date and time in Swift.
Choose SwiftDate for your next project, or migrate over your existing projects—you'll be happy you did!
★★ Star our github repository to help us! ★★
Created by Daniele Margutti (@danielemargutti)
- Swift 4.x: >= 4.4.0 - Latest is 4.5.1 Download here (
pod 'SwiftDate'
) - Swift 3.x: Latest compatible version is 4.3.0 Download here. If you are using CocoaPods be sure to fix the release (
pod 'SwiftDate', '~> 4.3.0'
)
Here's a highlight of the main features you can find in SwiftDate:
- Simple math operations with dates! Example:
aDate + 2.weeks + 1.hour or (1.year - 2.hours + 16.minutes).fromNow()
- Easy conversions to and from timezone, locale and calendar. Use the helper class
DateInRegion
and perform conversions with components and operations! - Compare dates with math operators
<,>,==,<=,>=
. For example, you can doaDate1 >= aDate2 or aDate1.isIn(anotherDate,.day)
- Easily work with time components. E.g.
aDateInRegion.day
orhour
,minutes
etc. expressed in your favourite timezone! - Easy and optimized way to get and transform a date from and to strings: supports both colloquial (human readable) and fixed formats (ISO8601, AltRSS, RSS, Extended, .NET and custom string as per Unicode standard)
- Express time interval in other time units; for example
120.seconds.in(.minutes) // 2 minutes
- Many shortcuts to get intervals, work with time units, intervals and common date operations (
isYesterday,isTomorrow,isBefore()
...) - ... many many other shiny things!
I'm also working on several other projects you may like. Take a look below:
Library | Description |
---|---|
SwiftDate | The best way to manage date/timezones in Swift |
Hydra | Write better async code: async/await & promises |
Flow | A new declarative approach to table managment. Forget datasource & delegates. |
SwiftRichString | Elegant & Painless NSAttributedString in Swift |
SwiftLocation | Efficient location manager |
SwiftMsgPack | Fast/efficient msgPack encoder/decoder |
- Check our website http://malcommac.github.io/SwiftDate/index.html to learn more about all available functions with a comprehensive list of examples
- Install SwiftDate via CocoaPods, Carthage or Swift Package Manager
- Have fun!
- On http://malcommac.github.io/SwiftDate/index.html to learn more about all available functions with a comprehensive list of examples
- The latest full class documentation is available here
Code is documented for Xcode, so you can use the built-in documentation panel to learn more about the library.
You can also generate the latest documentation using Jazzy; install Jazzy via gem install jazzy
then, from terminal, move to the /SwiftDate
folder and type jazzy -c jazzy.yaml
. Documentation will be generated in docs
folder.
- If you need help, use Stack Overflow. (Tag 'swiftdate')
- If you'd like to ask a general question, use Stack Overflow.
- If you found a bug, and can provide steps to reliably reproduce it, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
- Swift 4.x: >= 4.4.0 - Latest is 4.5.1 Download here.
- Swift 3.x: Latest compatible version is 4.3.0 Download here
- Swift 2.3: Latest compatible version is 3.0.9 on swift_23 branch
A complete list of changes for each release is available in the CHANGELOG file.
Currently we need translations for SwiftDate.bundle. Help us with a pull request!
Currently SwiftDate supports:
- English (since 4.0.0)
- Italian (since 4.0.0)
- German (made by to hackolein, since 4.0.3)
- Dutch (made by hout, since 4.0.0)
- French (made by pierrolivier, since 4.0.5)
- Indonesian (made by suprie, since 4.0.5)
- Simplified Chinese (made by codingrhythm, since 4.0.5)
- Traditional Chinese (made by rynecheow, since 4.0.7)
- Spanish (made by adrimarti and Sepho, since 4.0.8)
- Czech (made by rbukovansky, since 4.0.8)
- Danish (made by emilpedersen, since 4.0.8)
- Slovak (made by beretis, since 4.0.8)
- Korean (made by KisukPark, since 4.0.8)
- Turkish (made by fatihyildizhan, since 4.0.8)
- Vietnamese (made by solbadguyky, since 4.0.9)
- Japanese (made by bati668, since 4.0.9)
- Brazilian Portuguese (made by ipedro, since 4.0.11)
- Hebrew (made by @ilandbt, since 4.0.12)
- Swedish (made by @traneHead and @deville, since 4.0.12, updated in 4.1.0)
- Arabic (made by @abdualrhmanIO, since 4.0.13)
- Greek (made by @dimitris-c, since 4.10)
- Hungarian (made by @iKiKi, since 4.16)
- Azerbaijani Latin (made by @Elshad, since 4.19)
- Russian (made by roor, since 4.3.0)
- Persian (made by Seyed Mojtaba Hosseini Zeidabadi, since 4.4.2)
- Malay/Malaysia Latin (made by Mohd Hafiz, since 4.5.0)
- Polish (made by Grzegorz Krukowski, since 4.5.1)
Make a pull request and add your language!
SwiftDate supports multiple methods for installing the library in a project.
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SwiftDate in your projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.0.1+ is required to build SwiftDate 4+ (along with Swift 3 and Xcode 8).
- Swift 4.x: >= 4.5.1 Download here.
- Swift 3.x: Latest compatible version is 4.3.0 Download here
- Swift 2.3: Latest compatible version is 3.0.9 on swift_23 branch
To integrate SwiftDate into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'TargetName' do
use_frameworks!
pod 'SwiftDate', '~> <VERSION>'
end
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate SwiftDate into your Xcode project using Carthage, specify it in your Cartfile
:
github "malcommac/SwiftDate" ~> <VERSION>
Run carthage
to build the framework and drag the built SwiftDate.framework
into your Xcode project.
Current version is compatible with:
- Swift 4 or later
- iOS 8 or later
- macOS 10.10 or later
- watchOS 2.0 or later
- tvOS 9.0 or later
- ...and virtually any platform which is compatible with Swift 3 and implements the Swift Foundation Library
Are you searching for an old (unsupported) SwiftDate version? Check out:
- Swift 4.x: >= 4.5.1 Download here.
- Swift 3.x: Latest compatible version is 4.3.0 Download here
- Swift 2.3: Latest compatible version is 3.0.9 on swift_23 branch
- Swift 2.2: Latest compatible version is 3.0.8
SwiftDate is owned and maintained by Daniele Margutti along with main contributions of Jeroen Houtzager.
As open source creation any help is welcome!
The code of this library is licensed under MIT License; you can use it in commercial products without any limitation.
The only requirement is to add a line in your Credits/About section with the text below:
Date and Time Management is provided by SwiftDate - http://www.swift-date.com
Created by Daniele Margutti and licensed under MIT License.
We are interested in making a list of all projects which use this library. Feel free to open an Issue on GitHub with the name and links of your project; we'll add it to this site.