zoukankan      html  css  js  c++  java
  • Date——时间戳转化为YYYY-MM-DD h:m:s时间格式

    /**
     * example new Date(times)
     * @param time Date
     * @param fmt "yyyy-MM-dd" /"yyyy-MM-dd hh:mm:ss"
     * @returns String
     */
    
    function dateString (time, fmt) {
        var o = {
            "M+": time.getMonth() + 1, //月份
            "d+": time.getDate(), //日
            "h+": time.getHours(), //小时
            "m+": time.getMinutes(), //分
            "s+": time.getSeconds(), //秒
            "q+": Math.floor((time.getMonth() + 3) / 3), //季度
            "S": time.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (time.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
    

     

  • 相关阅读:
    sql_LIKE
    sql_TOP
    oracle_存储过程
    注释@
    request.getAttribute()和request.getParameter()区别
    遍历map
    ORACLE
    JSP
    生成导入模板_设置列宽及标题_解析xml
    解析Excel_Poi
  • 原文地址:https://www.cnblogs.com/zhangym118/p/8676597.html
Copyright © 2011-2022 走看看