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

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)
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 当初觉得很有缘分,才加了微信,后来却不了了之。朋友圈里总有一些人,互相不说话,但会互相点赞!
    鲜语999阅读 2,299评论 0 0
  • 每天的午睡一定得睡,降低情绪炸机的几率; 每天的微笑一定要多,增加情绪平和的几率; 事情脱离了控制,超出自己的想象...
    Firewinter阅读 1,567评论 0 0
  • 范雨素火了!一夜爆红,持续刷屏! 很多人和我一样,开始探究,究竟是什么因素成就了范雨素的一夜爆红? 记得读幼师时,...
    梦甜甜2011阅读 3,240评论 0 5

友情链接更多精彩内容