Skip to content

Instantly share code, notes, and snippets.

@dlsolution
Created January 18, 2021 07:03
Show Gist options
  • Save dlsolution/83f20960bbdd781b4ab4784d5e99066f to your computer and use it in GitHub Desktop.
Save dlsolution/83f20960bbdd781b4ab4784d5e99066f to your computer and use it in GitHub Desktop.
dates-in-swift.md

Objects for working with Date in Swift's Foundation framework:

  • Date: This is a struct that represents a specific point in time independent of any calendar or time zone. It has methods for creating dates, comparing dates and calculating time intervals between dates. It is not responsible for the date format or conversions between string and date.

  • DateFormatter: It provides methods for converting Date to String and String to Date. You can customise the date string using predefined styles in DateFormatter.Style or create your own custom format.

  • DateComponents: This is a Date or Time object represented in units such as the year, month, day, minute or hour in a particular calendar. It provides direct access to different parts of a date or time.

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment