SwiftDate

swiftdate

        // 获取当前date
        let date1 = Date.init()
        let data2 = "2015-07-26".date(format: DateFormat.custom("yyyy.mm.dd"), fromRegion: Region.Local())
        let date3 = DateInRegion.init(components: DateComponents.init(calendar: Calendar.autoupdatingCurrent, timeZone: TimeZone.current, era: 1, year: 2010, month: 1, day: 1, hour: 1, minute: 1, second: 1, nanosecond: 1, weekday: nil))
        // dataregion 修改时间元素值
        let date4 = date3! + 14.minutes + 12.seconds
        // 比较时间
        let bv = date3! > date4
        // 时间起始值
        let date5 = date4.startOf(component: Calendar.Component.hour)
        let date6 = date4.endOfDay

        // 时间戳
        let inter1 = TimeInterval.init("1244")!
        let date7 = Date.init(timeIntervalSinceNow: inter1)
        date7.inLocalRegion()


        // 获取多个时间中的最靠前
        let date8 = DateInRegion.oldestDate([date5,date6])


        // 获取字符串
        let date1Str = date1.string(format: DateFormat.custom("YYYY-MM-DD"), in: Region.Local())
        let dateStr1 = data2?.string(dateStyle: DateFormatter.Style.medium, timeStyle: DateFormatter.Style.short)
        //

你可能感兴趣的:(SwiftDate)