Coding Explorer Blog

Exploring how to code for iOS in Swift and Objective-C

  • Home
  • Apps
  • About
  • Contact

Date — Class Reference

Xcode 11.6 Swift 5.2.4

Last updated on August 12, 2020

An NSDate object specifies a particular point in time.  Despite “date” being in its name, it really stores time, of which the date is a component.  Under the hood, NSDates (as far as the public superclass we can see is concerned) are specified as a number of seconds past a reference date.  NSDate’s reference date is the first moment of January 1, 2001 in the GMT timezone.  These seconds are stored as a Double, which allows NSDate to range from milliseconds to years.  What we see as an NSDate is actually an abstract public superclass for a cluster of classes related to dates.  The internal classes are private, so talking about them here wouldn’t be particularly helpful, and it is probably best not to mess with them anyway.

Since Swift 3 though, most “NS” prefixes were removed from the Swift Standard Library, so now it is simply called “Date”.  If you need to save a timestamp for something in your iOS app, or maybe have a countdown timer for an app or game, you will be dealing with the Date class, so let’s take a look at it.
[Read more…]

Filed Under: Uncategorized

Subscribe to the Coding Explorer Newsletter

* indicates required

Follow Us

Facebooktwitterrss

Recent Posts

  • Error Handling in Swift
  • Creating and Modifying a URL in your Swift App
  • Watch Connectivity in Swift — Application Context
  • watchOS Hello World App in Swift
  • API Availability Checking in Swift

Categories

  • Class Reference
  • General
  • Interface Builder
  • My Apps
  • Objective-C
  • Swift
  • Syntax
  • Tutorial
  • Uncategorized

Archives

  • May 2016
  • March 2016
  • February 2016
  • December 2015
  • July 2015
  • June 2015
  • April 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • January 2014
  • November 2013
  • September 2013
  • August 2013
  • July 2013
  • Terms Of Use
  • Privacy Policy
  • Affiliate Disclaimer

Subscribe to the Coding Explorer Newsletter

* indicates required

Copyright © 2025 Wayne Media LLC · Powered by Genesis Framework · WordPress