JS 时间处理和格式转换
来源:互联网 发布:网卡mac地址哪个是 编辑:程序博客网 时间:2024/05/20 18:54
一。时间加减,日期加减,年月日加减一样。
var mydate= new Date('2012-05-10 10:10:21');
mydate.setDate(mydate.getDate()+50); //当前时间加50天
格式转换
Date.prototype.format = function(format)
{
varo = {
"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
}
var mydate= new Date('2012-05-10 10:10:21');
mydate.setDate(mydate.getDate()+50);
mydate.setMinutes(min, sec, ms)
alert(mydate.format("yyyy-MM-dd hh:mm:ss"));
By:lsfhack Email:lsfhack@163.com QQ:858084865
0 0
- JS 时间处理和格式转换
- JS 时间处理和格式转换
- JS 时间处理和格式转换
- JS 时间处理和格式转换
- 时间格式 前台转换和 sql处理
- js时间格式转换
- js时间格式转换
- JS时间格式转换
- js时间格式转换
- js时间格式转换
- js时间格式转换
- JS转换时间格式
- js转换时间格式
- js时间格式转换
- JSON 时间格式 转换
- ASP 时间格式 处理
- js时间格式处理
- js时间格式的转换 和时间的计算
- 在spring中配置hibernate的二级缓…
- BeanPropertyRowMapper类详解
- spring中文api下载
- BeanUtils的copyProperties的效率…
- hibernate级联保存更新
- JS 时间处理和格式转换
- Server 2000/2005 分页
- mssql2000分页查询
- Microsoft+Office++2007+文件格式…
- stuts2中使用json传输数据
- IT人生 需要指引<转自:51cto>
- 论坛注册、登陆、发帖、回帖弹出下…
- jquery获取同一根页面上多个radio…
- eclipse启动参数