//日期格式化
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.prototype.getCountDays = function(month){
var curDate = new Date();
var curMonth = curDate.getMonth();
curDate.setMonth(month);
//日期的天数设置为0时,Date会改变为上个月的最后一天
curDate.setDate(0);
return curDate.getDate();
}
分享到:
相关推荐
Date.prototype.Format 日期格式化 Date.prototype.DateAdd 日期计算 Date.prototype.DateDiff 比较日期差 Date.prototype.toString 日期转字符串 Date.prototype.toArray 日期分割为数组 Date.prototype.DatePart ...
Date.prototype.Format 日期格式化 Date.prototype.DateAdd 日期计算 Date.prototype.DateDiff 比较日期差 Date.prototype.toString 日期转字符串 Date.prototype.toArray 日期分割为数组 Date.prototype.DatePart ...
JavaScript日期处理函数,包含日期格式化,获取两个日期的相差天数,获取指定日期的前一天,获取日期所在月份的天数等
一个简单易用的js时间类型格式化工具库(兼容IE)大小:4KB 例子: //引入timeFormatter.js //使用方式非常简单,创建一个timeFormatter实例,传入的对象可省略 var timeFormatter = new TimeFormatter({ ...
字符串转日期型+Js当前日期时间+日期验证+判断闰年+日期的天数差+日期格式化+日期所在年的第几周
javascript中对Date类型的常用操作小结 /** ...8. * (5)Date.prototype.format:日期格式化 9. * (6)Date.stringToDate:字符串转成日期类型 10. * (7)Date.daysBetween:计算两个日期的天数
与本地时区数据一致地格式化日期。 模块 将解析器指向文本日志目录,它将为您返回每一行的对象: { " date " : " 2014-06-30T18:53:44+08:00 " , " value " : " <@srn_> ZIGGAGAGAGAGA " } 解析器还将返回...
废话不多说了,主要通过以下七个方面给大家总结了时间处理相关知识。 1.获取当前时间 ...3.获取并格式化日期:年-月-日 function getFormatDate(time) { return time.getFullYear() + - + (time.getMonth()
Date.prototype.isLeapYear 判断闰年 Date.prototype.Format 日期格式化 Date.prototype.DateAdd 日期计算 Date.prototype.DateDiff 比较日期差 Date.prototype.toString 日期转字符串 Date.prototype.toArray 日期...
格式化日期时间 8.得到随机日期 复制代码 20.视频转换类 VideoConvert 1.获取文件的名字 2.获取文件扩展名 3.获取文件类型 4.视频格式转为Flv 5.生成Flv视频的缩略图 6.转换文件并保存在指定文件夹下 7.转换文件并...
日期格式处理类 DateUtil.cs 日期格式、闰月、计算当月天数等转换 文件实用类 FileUtil.cs 读取、备份、创建等文件操作 上传类 HtmlInputFileControl.cs 单个文件上传,控制文件格式大小 图片处理类 ImageUtil.cs ...
React日期 可定制,灵活且美味的React Date Picker。 通缉犯通缉 一直在寻找帮助您维护此插件的人员,请提交PR,我们可以实现这一目标! 例子 特征 移动友好 Redux格式兼容 独立选择器 多日历支持 禁止过去的日期 ...
格式化日期时间 8.得到随机日期 复制代码 20.视频转换类 VideoConvert 1.获取文件的名字 2.获取文件扩展名 3.获取文件类型 4.视频格式转为Flv 5.生成Flv视频的缩略图 6.转换文件并保存在指定文件夹下 7.转换文件并...
Hello World与React样板 该模板类似于create-react-app,但适用于4Geeks Academy学生。... 对于Windows,Mac,Linux或Gitpod,请通过实时重装启动Webpack服务器...其他特性自动代码格式化:使用进行自动代码缩进和格式化。