评论

ios 时间问题 转化

搞了好久 希望能用

//时间转换
timeFormat: function(time) {
var d = new Date(time.replace(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}).*$/, ‘$1Z’));

var year = d.getFullYear(); //年  
var month = d.getMonth() + 1; //月  
var day = d.getDate(); //日  

var hh = d.getHours(); //时  
var mm = d.getMinutes(); //分  
var ss = d.getSeconds(); //秒  

var clock = year + "/";

if (month < 10)
  clock += "0";

clock += month + "/";

if (day < 10)
  clock += "0";

clock += day + " ";

if (hh < 10)
  clock += "0";

clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm + ":";

if (ss < 10) clock += '0';
clock += ss;
return (clock);

},

最后一次编辑于  11-02  
点赞 0
收藏
评论

2 个评论