小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

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

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

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

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

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

//得到相差的 天數(shù) 和 小時(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; //小時(shí)
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ù)日期值時(shí),說(shuō)明日期值超過(guò)當(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>

  

分類(lèi): JavaScript

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

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多