代码改变世界

swift开发笔记04

2017-09-08 16:03  dengchaojie_learner  阅读(100)  评论(0编辑  收藏  举报

        let now = Date()

        let gregorian = Calendar.init(identifier: Calendar.Identifier.gregorian)

        let components = (gregorian as NSCalendar).components(NSCalendar.Unit.year, from: birthdayDP.date, to: now, options: [])

        let age = components.year