字符串类型日期用 年-月-日 形式显示
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
网友评论