JavaScript獲取距離某天前或后的日期

Alex1650 9年前發布 | 926 次閱讀 JavaScript JavaScript;Date

/**

  • 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 - n2436001000; 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 + n2436001000; result = new Date(millSecond); result = getTodayFormatea(result); return result; } </pre>

     

 本文由用戶 Alex1650 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!