js 中怎么定义或者重写 SimpleDateFormat 方法
解决方案 »
- 急!!!在线等,iframe 如何只要纵向滚动条,不要横向的呀???
- HibernateSessionFactory类运行到configuration.buildSessionFactory()这句话不运行下了,并且也没有报错
- eclipse 疑难杂症!
- 求救 ,hibernate 如何禁止缓存
- JSP页面中文乱码问题
- Java就业培训教程 燕子轻呢精品软件园提供高速下载
- struts 1.1 中,连接池对象只能在ACTION对象中使用马?
- jsp连接数据库的beans出错了!
- 怎样去掉/customer?aaa=sasasa...&bbb=fdfdfd...&pagenum=1中"pagenum="后面的数值(这个数值位数不定,这个url的长度不是固定的)?
- 请教jsp参数传递的问题------------我只有32分了,不好意思
- 点击后退按钮让页面失效问题,如何解决???
- 如何将编写好的JSP项目发布到服务器中?
//时间格式化
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 now = new Date();
alert(now.format("yyyy-MM-dd hh:mm:ss"));
alert(now.format("yyyy-MM-dd hh:mm:ss"));
var now2 = new Date();
alert(now2.format("yyyy-MM-dd"));
格式在format()方法里通过参数自己定义
我想转化其他的,该怎么做
那您给说说吧,假如说我想转一个名叫time 的,这个time 是我从后台取到的