Date to Month, Day, Year in Swift
Written on:July 24, 2014
0
NSDate and NSCalendar is a bit different in Swift. Here is a little bit of code to help you extract the month, day, and year from the current date. let flags: NSCalendarUnit = .DayCalendarUnit | .MonthCalendarUnit | .YearCalendarUnit let date = NSDate() let components = NSCalendar.currentCalendar().components(flags, fromDate: date) let year = components.year println(year) let month = components.month println(month) let day = components.day println(day)
Read more...In category: Development, Education
Tags:Apple , iOS , iOS 8 , Swift , Swift Programming Language , Xcode
Tags:Apple , iOS , iOS 8 , Swift , Swift Programming Language , Xcode