复制代码代码如下所示:
功能getMonths(日){
获取当前日期
VaR CURDATE =新的日期(日);
返回curdate.getmonth()+ 1;
};
功能getyears(日){
获取当前日期年份。
VaR CURDATE =新的日期(日);
返回curdate.getfullyear();
};
功能getcountdays(日){
转换时间
VaR CURDATE =新的日期(日);
获取当前月份
无功curmonth = curdate.getmonth();
/ *生成实际的月:因为curmonth将小于实际的1个月,所以有必要增加1。
curdate.setmonth(curmonth + 1);
日期设置为0
(0)curdate.setdate;
返回到月份的日子。
返回curdate.getdate();
};
*
默认是1天,默认是不返回到短时间昨天。
一天:开始时间
数量:分开的天数
IsShortTime:它表明短时间
* /
功能getbeforeday(日、金额、isshorttime){
如果(Date.parse(日)!= date.parse(天)){
返回false;
}
var天=新日期(新日期(日)- 1000 * 60 * 60 * 24);
如果(数量){
VaR值= parseInt(量);
如果(编号> 0)!IsNaN(数)){
日期=新日期(新日期(日)- 1000×60×60×24××);
}
}
返回日期格式(天,isshorttime);
}
*
要想在明天开始,默认是1天,默认是不返回到短时间。
一天:开始时间
数量:分开的天数
IsShortTime:它表明短时间
* /
功能getafterday(日、金额、isshorttime){
如果(Date.parse(日)!= date.parse(天)){
返回false;
}
日期=新日期(日);
var v = day.valueof();
var =新日期((V + 86400000));
如果(数量){
VaR值= parseInt(量);
如果(编号> 0)!IsNaN(数)){
日期=新日期((V + 86400000××));
}
}
返回日期格式(天,isshorttime);
}
*
格式化时间,默认是不返回短时间。
天:戴特
IsShortTime:它表明短时间
* /
功能DateFormat(天,isshorttime){
如果(Date.parse(日)!= date.parse(天)){
返回false;
}
var =新日期(日);
如果(isshorttime isshorttime = = true){
无功小时= days.gethours()<10 0 + days.gethours():days.gethours();
VaR分钟= days.getminutes()<10 0 + days.getminutes():days.getminutes();
VaR秒= days.getseconds()<10 0 + days.getseconds():days.getseconds();
返回days.getfullyear()+-+(days.getmonth()+ 1)+-+ days.getdate()++时间+:+时间+:+秒;
其他{ }
返回days.getfullyear()+-+(days.getmonth()+ 1)+-+ days.getdate();
}
}