美文网首页
字符串类型日期用 年-月-日 形式显示

字符串类型日期用 年-月-日 形式显示

作者: lalala1112389 | 来源:发表于2017-12-19 18:10 被阅读0次
    let commenttime = "\(dict["newsoccurrencetime"]!)"
            let timestampIntInMsec = Int.init(commenttime)
            let timestampDoubleInSec:Double = Double(timestampIntInMsec!)/1000
            print("timestampDoubleInSec=\(timestampDoubleInSec)")
            let parsedDate:NSDate = NSDate(timeIntervalSince1970: TimeInterval(timestampDoubleInSec))
            print("parsedDate=\(parsedDate)")
            
            let date = "\(parsedDate)".substring(to: 10)
            
            let newsOccurrencenTimeFrame = CGRect.init(x: newsSresourceLabel.frame.maxX + 12, y: newsSresourceLabel.frame.minY, width: 200, height: 40)
            let newsOccurrencenTimeLabel = UILabel.init(frame: newsOccurrencenTimeFrame)
            newsOccurrencenTimeLabel.text = date
            newsOccurrencenTimeLabel.textColor = UIColor("#999999")
            newsOccurrencenTimeLabel.font = UIFont.systemFont(ofSize: 13)
            newsOccurrencenTimeLabel.sizeToFit()
            bgView.addSubview(newsOccurrencenTimeLabel)

    相关文章

      网友评论

          本文标题:字符串类型日期用 年-月-日 形式显示

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