-
js日期
- Date.prototype.Format = function (fmt) {
- 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(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
-
- 调用:
- var time1 = new Date().Format("yyyy-MM-dd");
- var time2 = new Date().Format("yyyy-MM-dd HH:mm:ss");
-
- var nowTime=new Date();
- nowTime.setMonth(nowTime.getMonth()-1);
- alert(nowTime.Format("yyyy-MM-dd HH:mm:ss");)
-
相关阅读:
c++之类模板和函数模板的区别
c++之模板-类模板
c++之函数模板的局限性
c++之普通函数和模板函数的调用规则
c++之普通函数和模板函数的区别
c++之函数模板案例
c++之模板函数-模板
c++文件操作之二进制文件-读文件
c++文件操作之二进制文件-写文件
FFmpeg获取DirectShow设备数据(摄像头,录屏)
-
原文地址:https://www.cnblogs.com/go4mi/p/7687706.html
Copyright © 2020-2023
润新知