日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

js兩個日期相減得到月數(shù)和天數(shù)和時and計(jì)算 日期減去月之后的日期

 眺望太湖望亭閣 2013-10-26

js兩個日期相減得到月數(shù)和天數(shù)和時and計(jì)算 日期減去月之后的日期

//得到相差的 月份數(shù)

DateTime startDate = DateTime.Parse("2006-12-1");
DateTime endDate = DateTime.Parse("2006-02-25"); //結(jié)束時間-起始時間
int totalMonth = endDate.Year * 12 + endDate.Month - startDate.Year * 12 - startDate.Month;

//得到相差的 天數(shù) 和 小時

DateTime t1 = DateTime.Parse("2006-12-1");
DateTime t2 = DateTime.Parse("2006-02-25");
System.TimeSpan ts = t2 - t1;
int days = ts.Days; //天

int Hours= ts.Hours; //小時
TextBox1.Text = (days / 30).ToString();

 

-----------計(jì)算 日期減去月之后的日期

<strong>function aa(){<br>var str_dt = '2011/12/31';
var day = str_dt.substring(str_dt.lastIndexOf('/') + 1); //獲取源數(shù)據(jù)的天數(shù)值,這里是31
var dt = new Date(str_dt);
var result = [];
dt.setMonth(dt.getMonth() - 10);
result.push(dt.getFullYear());
//計(jì)算結(jié)果日期值<源數(shù)據(jù)日期值時,說明日期值超過當(dāng)月最大天數(shù),日期值修改為當(dāng)月最大天數(shù)值
if (dt.getDate() < day) {
result.push(dt.getMonth());
dt.setDate(0);
}
else result.push(dt.getMonth() + 1);
result.push(dt.getDate());
alert(result.join('/'));<br></strong>
<strong>}</strong>
<strong><br>
</strong>

  

分類: JavaScript

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多