微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angular4之时间戳转日期格式

前言:

最近在做前端的项目,刚开始做还是很羞涩的样子,不过好在有百度下大神的无私奉献还有我们家欢哥的热情帮助,这个问题解决了,宝宝只负责记录一下(虽然是我的任务)下面进入主题

之前:

之后:


之前我是在html中试着调ts中的方法,保存之前整个界面都没了,虽然你挺难看的但是这也太给面子了;屡试无效那就请我们家欢哥来吧(明智之举),欢哥帮我解决完问题还特别好的告诉我model和数组的区别,嘻嘻——一不小心小白的本性暴露了,上面呐废话说完了,上一下demo

 <td >
               <!--<span  (showTime)="convertToDate({{examInfo.examinationEntity.startingDate}})"></span>-->
               <li >
                {{examInfo.examinationEntity.startingDate}}
                 ---
                 {{examInfo.examinationEntity.endingDate}}
               </li>
            </td>

this.dataservice.getExamInfoByStudentId(this.url).subscribe(
              res => {
                this.examInfoModel = res['data'];
                this.examInfoModel.forEach(x=>{
                    x.examinationEntity.endingDate = this.convertToDate(x.examinationEntity.endingDate);//方法调用converToDate()
                    x.examinationEntity.startingDate = this.convertToDate(x.examinationEntity.startingDate);
                })
                console.log(this.examInfoModel);
                console.log("this.exampaper---"+this.examInfoModel.forEach.prototype)
                })
        }
    }

    convertToDate(Nows ){
       
       // return new Date(parseInt(date)*1000).toLocaleString().replace(/:d{1,2}$/,'')
       //return new Date(parseInt(date)*1000).toLocaleString().replace(/年|月/g,"-").replace(/日/g,' ')
        var Now=new Date(Nows);
        var year=Now.getFullYear();
        var month=Now.getMonth()+1;
        var date=Now.getDate();
        var hour=Now.getHours();
        var minute=Now.getMinutes();
        var second=Now.getSeconds();
        return year+"年"+month+"月"+date+"日  "+hour+":"+minute+":"+second; 
    }


http://www.cnblogs.com/sure2016/p/5978062.html 记得看评论

原文地址:https://www.jb51.cc/angularjs/146076.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐