当前位置: 移动技术网 > IT编程>网页制作>CSS > 时间转换解析

时间转换解析

2019年04月19日  | 移动技术网IT编程  | 我要评论

1、年月日与‘-’转换

function processdate(str) {
  if (str.indexof('-') != -1) {
    return str.substr(0, 10).replace('-', '年').replace('-', '月') + '日';
  } else {
    return str.replace('年', '-').replace('月', '-').replace('日', '');
  }
}

2、转换成07月20日 18:00

function gettimedate (time) {
  let show_day = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
  if (time && time.length > 10) {
    let week = new date(time.substring(0,10)).getday();
    let weeks = show_day[week];
    var yymmdd = time.split(" ")[0].split("-");
    var hhmmss = time.split(" ")[1].split(":");
    return yymmdd[1] + "月" + yymmdd[2] + "日 " + weeks + " "+hhmmss[0] + ":" + hhmmss[1];
  }
}

?

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网