博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JS时间格式化函数
阅读量:7033 次
发布时间:2019-06-28

本文共 826 字,大约阅读时间需要 2 分钟。

Date.prototype.format = function (format) {            var o = {                "M+": this.getMonth() + 1, //month                "d+": this.getDate(),    //day                "h+": this.getHours(),   //hour                "m+": this.getMinutes(), //minute                "s+": this.getSeconds(), //second                "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter                "S": this.getMilliseconds() //millisecond            }            if (/(y+)/.test(format)) format = format.replace(RegExp.$1,        (this.getFullYear() + "").substr(4 - RegExp.$1.length));            for (var k in o) if (new RegExp("(" + k + ")").test(format))                format = format.replace(RegExp.$1,        RegExp.$1.length == 1 ? o[k] :        ("00" + o[k]).substr(("" + o[k]).length));            return format;        }

 

转载地址:http://yhjal.baihongyu.com/

你可能感兴趣的文章
用两个栈模拟一个队列
查看>>
给浏览器网页标签页添加图标
查看>>
转载:Erlang 资源
查看>>
C++ 构造函数的对象初始化列表
查看>>
HTTP2.0
查看>>
企业架构 - 使用价值流分析找到价值所在
查看>>
Lintcode: Subarray Sum 解题报告
查看>>
自动定时重启sql server回收内存
查看>>
压力测试以及性能分析工具
查看>>
10款AJAX/CSS/HTML的在线表单生成器
查看>>
android之app widget(三)
查看>>
在 .NET 3.5 中序列化和反序列化 JSON
查看>>
flash左导航不显示
查看>>
SAP BW好文章链接
查看>>
C#防止WebBrowser在新窗口中打开链接页面
查看>>
MongoDB 2.4 RC2 (2.3 开发系列) 发行说明
查看>>
php.ini修改php上传文件大小限制(转)
查看>>
office2003 下载地址 及密码
查看>>
C# ORM—Entity Framework 之Code first(代码优先)(二)
查看>>
/etc/vim/vimrc的一个的配置
查看>>