将中国标准时间)转化为yyyy-MM-dd

有两种方法:

1.

var d = new Date(this.searchs.open_date[0]);
this.data2=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();

 

this.searchs.open_date[0]        是你要转化的时间









2.
  使用插件


http://momentjs.cn/ 这个是他的官网
 var d = new Date(this.searchs.open_date[0]);
this.data=moment(this.searchs.open_date[0]).format('YYYY-MM-DD HH:mm:ss')

  

posted @ 2018-11-12 17:53  1点  阅读(1461)  评论(0编辑  收藏  举报