JavaScript获取距离某天前或后的日期
2018-07-20 来源:open-open
/**
* param Date Object:Mon May 11 13:53:08 UTC+0800 2015
* n 自param 起向后多少天
* return Date Object:Mon May 11 13:53:08 UTC+0800 2015
*/
function getDateBeforeParamDate(param,n){
var result = new Date();
if(param==null){
param = result;
}
if(n==null){
n=0;
}
param = new Date(param);
millSecond = param.valueOf();
millSecond = millSecond - n*24*3600*1000;
result = new Date(millSecond);
result = getTodayFormatea(result);
return result;
}
/**
* param Date对象:Mon May 11 13:53:08 UTC+0800 2015
* n 自param 向前多少天
* return Date Object:Mon May 11 13:53:08 UTC+0800 2015
*/
function getDateNextParamDate(param,n){
var result = new Date();
if(param==null){
param = result;
}
if(n==null){
n=0;
}
param = new Date(param);
millSecond = param.valueOf();
millSecond = millSecond + n*24*3600*1000;
result = new Date(millSecond);
result = getTodayFormatea(result);
return result;
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐