美文网首页
iOS swift-返回当前时间的时间戳

iOS swift-返回当前时间的时间戳

作者: 青菜白玉堂 | 来源:发表于2017-04-27 20:20 被阅读232次

    //返回当前时间的时间戳

    class func YhyGetTimeCHUO() -> Int{

    //获取当前时间

    let now = NSDate()

    // 创建一个日期格式器

    let dformatter = DateFormatter()

    dformatter.dateFormat = "yyyy年MM月dd日 HH:mm:ss"

    print("当前日期时间:\(dformatter.string(from: now as Date))")

    //当前时间的时间戳

    let timeInterval:TimeInterval = now.timeIntervalSince1970

    let timeStamp = Int(timeInterval)

    return timeStamp

    }

    相关文章

      网友评论

          本文标题:iOS swift-返回当前时间的时间戳

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