日期转换的问题-- datatime类型正确格式yy-mm-dd hh:mm:ss 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>var d = new Date();d = formatDateTime(d,"datetime");//就可以直接把d的值提交到数据库了.alert(d);function formatDateTime(date, mode){/* *--------------- formatDateTime(date, mode) ----------------- *formatDateTime(date, mode) * 功能:格式化时间的输入出格式. * 参数:date,时间实例. * 参数:mode,字符串:"date","time","datetime" * 返回:时间输出字符串 *--------------- formatDateTime(date, mode) ----------------- */ function getDateString(date){ var years=date.getFullYear(); var months=date.getMonth()+1; var days=date.getDate(); if (months<10) months="0"+months; if (days<10) days="0"+days; return years+"-"+months+"-"+days; } function getTimeString(date){ var hours=date.getHours(); var minutes=date.getMinutes(); var seconds=date.getSeconds(); if (hours<10) hours="0"+hours; if (minutes<10) minutes="0"+minutes; if (seconds<10) seconds="0"+seconds; return hours+":"+minutes+":"+seconds; } if (typeof(date)=="object" && !isNaN(date)){ if (!mode) mode="datetime"; switch (mode){ case "date":{ return getDateString(date); break; } case "time":{ return getTimeString(date); break; } case "datetime":{ return getDateString(date)+" "+getTimeString(date); break; } default:{ return getDateString(date)+" "+getTimeString(date); break; } } } else return "";}</script> 问题求解 CSS教程 当图片获得焦点时,如果改变该图片的大小 javascript验证简单的数学公式该如何写?谢谢! 请问在表单中怎样把回车键改成Tab键 求教:Html 5 中canvas.toDataURL方法报SecurityError错误 ,怎么解决 ?? 推荐8款简单大气的JQuery/CSS3图片特效焦点图 JSP能清楚window.history的内容么? jquery取值问题。 如何设置横向打印? 我从word里复制一些东西到我的再现编辑器,结果那些内容里有好多看不懂的代码,使我的在线编辑器编辑老是出错,请问怎么解决 在IE中屏蔽退格键(Back Space)问题?
var d = new Date();
d = formatDateTime(d,"datetime");
//就可以直接把d的值提交到数据库了.
alert(d);function formatDateTime(date, mode)
{
/*
*--------------- formatDateTime(date, mode) -----------------
*formatDateTime(date, mode)
* 功能:格式化时间的输入出格式.
* 参数:date,时间实例.
* 参数:mode,字符串:"date","time","datetime"
* 返回:时间输出字符串
*--------------- formatDateTime(date, mode) -----------------
*/
function getDateString(date){
var years=date.getFullYear();
var months=date.getMonth()+1;
var days=date.getDate(); if (months<10) months="0"+months;
if (days<10) days="0"+days; return years+"-"+months+"-"+days;
} function getTimeString(date){
var hours=date.getHours();
var minutes=date.getMinutes();
var seconds=date.getSeconds(); if (hours<10) hours="0"+hours;
if (minutes<10) minutes="0"+minutes;
if (seconds<10) seconds="0"+seconds; return hours+":"+minutes+":"+seconds;
} if (typeof(date)=="object" && !isNaN(date)){
if (!mode) mode="datetime";
switch (mode){
case "date":{
return getDateString(date);
break;
}
case "time":{
return getTimeString(date);
break;
}
case "datetime":{
return getDateString(date)+" "+getTimeString(date);
break;
}
default:{
return getDateString(date)+" "+getTimeString(date);
break;
}
}
}
else
return "";
}
</script>