Last active
May 4, 2017 03:31
-
-
Save jianghaoyuan2007/82a3f01b5d99bad020e49b69091ba155 to your computer and use it in GitHub Desktop.
A Simple Date Component Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let calendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian) | |
let units: NSCalendar.Unit = [.hour, .minute, .second] | |
let date = Date() | |
let dateComponents = calendar!.components(units, from: date) | |
print(dateComponents) // hour: 11 minute: 26 second: 33 isLeapMonth: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment