JS格式时间
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; }
说明:获取到时间var time = new Date().format("yyyy-MM-dd hh:mm:ss");
最新文章
- 好用的wget命令从下载添加环境变量到各参数详解
- 更新日志 - BugHD 新增邮件告警功能
- sharepoint 开发相关工具总结
- vscode 编写python如何禁止 flake8 提示 line too long
- MST:Conscription(POJ 3723)
- UIcollectionView的使用(首页的搭建1)
- Spring+SpringMVC+Mybatis+MAVEN+Eclipse+项目完整环境搭建
- Jackknife,Bootstraping, bagging, boosting, AdaBoosting, Rand forest 和 gradient boosting的区别
- git clone出现SSL错误
- 内存管理 (C++)
- Java8函数之旅 (五) -- Java8中的排序
- oracle01
- kali linux 安装wps office
- Java中Dom4j解析XML
- python - logging模块应用
- Masm615+notepad++6.8.8搭建汇编开发环境
- Qt 4.8.2.+VS2008静态编译
- 配置SpringMvc + maven 数据源!(四)
- Scala 方法和函数
- vue.js2.0+elementui ——>; 后台管理系统