mysql从当前月向前推12_JavaScript获取当前时间向前推三个月的方法示例
本文實(shí)例講述了JavaScript獲取當(dāng)前時(shí)間向前推三個(gè)月的方法。分享給大家供大家參考,具體如下:
/p>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Testfunction get3MonthBefor(){
var resultDate,year,month,date,hms;
var currDate = new Date();
year = currDate.getFullYear();
month = currDate.getMonth()+1;
date = currDate.getDate();
hms = currDate.getHours() + ':' + currDate.getMinutes() + ':' + (currDate.getSeconds() < 10 ? '0'+currDate.getSeconds() : currDate.getSeconds());
switch(month)
{
case 1:
case 2:
case 3:
month += 9;
year--;
break;
default:
month -= 3;
break;
}
month = (month < 10) ? ('0' + month) : month;
resultDate = year + '-'+month+'-'+date+' ' + hms;
return resultDate;
}
document.write(get3MonthBefor());
運(yùn)行效果圖如下:
PS:這里再為大家推薦幾款時(shí)間及日期相關(guān)工具供大家參考使用:
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
總結(jié)
以上是生活随笔為你收集整理的mysql从当前月向前推12_JavaScript获取当前时间向前推三个月的方法示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mysql 建立root用户名和密码_M
- 下一篇: sqlmap 连接mysql_sqlma