惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
博客园 - 司徒正美
罗磊的独立博客
D
Docker
Last Week in AI
Last Week in AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
V
V2EX
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园 - 叶小钗
B
Blog RSS Feed
A
About on SuperTechFans
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
P
Proofpoint News Feed

博客园 - Daniel Pang

pcanywhere失去连接的一个解决方法 [软件共享]将数据库中的数据导出为SQL脚本 对文件下载的补充 - Daniel Pang - 博客园 复制DataTable的一种方法 IBatisNet + Castle 开发相关文章 [IBatisNet]关于返回DataTable的一点问题 深圳电话订票基本步骤及所有的取票点地址电话 Automatic Transaction Management Facility 使用 - Daniel Pang IBatisnet Facility 的几种配置 - Daniel Pang IBatisNet -- 保护你的配置文件及映射文件信息 Rational Rose 加载出错的问题 修改Sql server中列的属性脚本 字符串加密方法 ERP术语 英文对照(部分)(参考) 一个关于SQL2005的问题 动态加载TreeNode -- ComponentArt TreeView - Daniel Pang 使用IBatisNet + Castle 开发DotNet软件 JS--屏蔽浏览器右键菜单 Excel的导出操作 - Daniel Pang - 博客园
JS格式化日期字符串 - Daniel Pang - 博客园
Daniel Pang · 2008-02-29 · via 博客园 - Daniel Pang

 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