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 记得看评论

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...