美文网首页
2020-12-16

2020-12-16

作者: 怪先生哦 | 来源:发表于2020-12-16 18:03 被阅读0次

swift-Date时间比较

    letdate1=Date()

    letdate2=Date()

    // date1 < date2 升序排列

    ifdate1?.compare(date2!) == .orderedAscending

    {

          print("<")

    }

    //date1 = date2 相等

    ifdate1?.compare(date2!) == .orderedSame

    {

          print(" = ")

    }

    //降序排列的 date1 > date2 降序排列

    ifdate1?.compare(date2!) == .orderedDescending

    {

        print(">")

    }

相关文章

网友评论

      本文标题:2020-12-16

      本文链接:https://www.haomeiwen.com/subject/bqrogktx.html