/**
* 扩展date函数
* author:c3gen
*/ Date.prototype.format = function(format) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
}
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;
} /**
date 为long类型
pattern 为格式化参数
*/
function getFormatDate(date, pattern) {
if (date == undefined) {
date = new Date();
}
if (pattern == undefined) {
pattern = "yyyy-MM-dd hh:mm:ss";
}
return date.format(pattern);
} $(function() {
var s = new Date(1388776825);
alert(s);
alert(getFormatDate(s));
})

最新文章

  1. 浅析call和apply
  2. LruCache详解之 Android 内存优化
  3. Android APK反编译就这么简单 详解(附图)
  4. javaweb学习总结(九)—— 通过Servlet生成验证码图片
  5. BZOJ-1901 Zju2112 Dynamic Rankings 函数式线段树 套 树状数组+离线处理
  6. Android控件大全(三)——RecyclerView
  7. HttpRuntime.Cache被清空的DataTable
  8. IIS配置及防黑
  9. java MYSQL做分页
  10. ABAP ALV DEMO示例源码
  11. bzoj1662: [Usaco2006 Nov]Round Numbers 圆环数
  12. Python中使用Flask、MongoDB搭建简易图片服务器
  13. KNN算法理解
  14. dev repositoryItem 手工定义
  15. tomcat启动不了,内存溢出
  16. 关于无法下载android开发工具的解决方法
  17. fgrep: ifcfg-ifcfg-eth0: No such file or directory
  18. python hex() oct() bin() math 内置函数
  19. ionic 页面传递参数
  20. codeforces round#510

热门文章

  1. Ubuntu搭建Ruby on Rails环境
  2. <Oracle Database>物理结构
  3. c# WebBrower 与 HttpRequest配合 抓取数据
  4. hdu 2896 AC自动机
  5. 绿色ip扫描工具
  6. android wifi 获取扫描结果
  7. 套题 codeforces 361
  8. JavaScript 基础第二天
  9. Win10 无法完全关机问题
  10. DirectXMath