zoukankan      html  css  js  c++  java
  • JS格式化日期字符串

     1//格式化日期
     2Date.prototype.format = function(format)
     3{
     4    var o =
     5    {
     6        "M+" : this.getMonth()+1//month
     7        "d+" : this.getDate(),    //day
     8        "h+" : this.getHours(),   //hour
     9        "m+" : this.getMinutes(), //minute
    10        "s+" : this.getSeconds(), //second
    11        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
    12        "S" : this.getMilliseconds() //millisecond
    13    }

    14    if(/(y+)/.test(format))
    15    format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
    16    for(var k in o)
    17    if(new RegExp("("+ k +")").test(format))
    18    format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
    19    return format;
    20}

    21
  • 相关阅读:
    Jedis入门
    redis的安装
    redis概述
    020 SpringMVC返回Json
    019 数据绑定流程分析(校验)
    018 数据绑定流程分析(包括数据转换与格式化)
    maven添加插件,与maven打包
    定制库到maven库
    maven仓库
    Maven启动代理访问
  • 原文地址:https://www.cnblogs.com/pw/p/1085768.html
Copyright © 2011-2022 走看看