zoukankan      html  css  js  c++  java
  • js日期格式化

     //格式化
    function timeCon2(obj){
    if(obj==""||obj==undefined){
    return false;
    }else{
    var timeHtml = "";
    var time = obj;
    time = time.split(' ');
    var year = time[2]//年
    var day = time[1].replace(',','');//日
    var wen = time[3];//时分秒
    var non = time[4];//上午or下午
    var month = ""//月
    if(non=="AM"){
    non = "上午";
    }else if(non=="PM"){
    non = "下午"
    }
    if(time[0]=='Jan'){//一月
    month = "1";
    }else if(time[0]=='Feb'){//二月
    month = "2";
    }else if(time[0]=='Mar'){//三月
    month = "3";
    }else if(time[0]=='Apr'){//四月
    month = "4";
    }else if(time[0]=='May'){//五月
    month = "5";
    }else if(time[0]=='Jun'){//六月
    month = "6";
    }else if(time[0]=='Jul'){//七月
    month = "7";
    }else if(time[0]=='Aug'){//八月
    month = "8";
    }else if(time[0]=='Sep'){//九月
    month = "9";
    }else if(time[0]=='Oct'){//十月
    month = "10";
    }else if(time[0]=='Nov'){//十一月
    month = "11";
    }else if(time[0]=='Dec'){//十二月
    month = "12";
    }

    timeHtml+=year+'-'+month+'-'+day+'  '+wen;
    return timeHtml;
    }

    }
  • 相关阅读:
    20189207《网络攻防实践》第一周作业
    事件冒泡
    链接分类
    JS:offsetWidth\offsetleft
    JS alert()、confirm()、prompt()的区别
    this用法
    事件绑定
    clippath
    浅谈正则
    C++大师Lippman:我对中国程序员的忠告(转载)
  • 原文地址:https://www.cnblogs.com/java0619/p/5138047.html
Copyright © 2011-2022 走看看