js如何格式这个时间格式啊??求救各位大佬! 时间格式:Sat Feb 19 23:48:12 +0800 2011,希望格式化成yyyy/MM/dd hh:mm:ss 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function formatDate(sDate){ var month = {"jan":1, "feb":2, "mar":3, "apr":4, "may":5, "jun":6, "jul":7, "aug":8, "sept":9, "oct":10, "nov":11, "dec":12} var arr = sDate.toLowerCase().split(' '); return [arr[5], month[arr[1]], arr[2]].join("/") + " " + arr[3]; } alert(formatDate("Sat Feb 19 23:48:12 +0800 2011")); 要是我,我就用sql转换一下select to_char(time,'yyyy-mm-dd hh24:mi:ss') from dual ///格式日期 Date.prototype.format = function(format) { var o ={ 'M+' : this.getMonth()+1, //month 'd+' : this.getDate(), //day 'h+' : this.getHours(), //hour 's+' : this.getSeconds(), //second 'm+' : this.getMinutes(), //minute '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; };alert(new Date().format('yyyy-MM-dd hh:mm:ss')); jstl标签就可以了 <fn:formatDate value="" pattern=""/> 大家认识这种web插件么? 一张表单用到多个带提示的输入框该怎么做? js函数修改全局变量 javascript能控制radio的项吗? Cookie存储出现问题了(在线等!) 无刷新获取服务器数据返回客户端???,谢谢 js连接数据库,高手请进 请问如何设置一个table不可见,用button的事件,比较弱,请帮忙? 怎么实现网页模块随鼠标滚动而滚动? 求指教,写了个连接mysql的模糊搜索的代码,tomcat运行有错、但是不知道错在哪里 如何重写 alert,confirm,prompt 服务器无法响应我的请求?
function formatDate(sDate){
var month = {"jan":1, "feb":2, "mar":3, "apr":4, "may":5, "jun":6, "jul":7, "aug":8, "sept":9, "oct":10, "nov":11, "dec":12}
var arr = sDate.toLowerCase().split(' '); return [arr[5], month[arr[1]], arr[2]].join("/") + " " + arr[3]; }
alert(formatDate("Sat Feb 19 23:48:12 +0800 2011"));
select to_char(time,'yyyy-mm-dd hh24:mi:ss') from dual
Date.prototype.format = function(format)
{
var o ={
'M+' : this.getMonth()+1, //month
'd+' : this.getDate(), //day
'h+' : this.getHours(), //hour
's+' : this.getSeconds(), //second
'm+' : this.getMinutes(), //minute
'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;
};alert(new Date().format('yyyy-MM-dd hh:mm:ss'));