這篇文章給大家分享的是有關(guān)C#中計(jì)算傳入的時(shí)間距離今天的時(shí)間差的案例的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考。一起跟隨小編過來看看吧。
創(chuàng)新互聯(lián)建站專注于橫峰網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供橫峰營銷型網(wǎng)站建設(shè),橫峰網(wǎng)站制作、橫峰網(wǎng)頁設(shè)計(jì)、橫峰網(wǎng)站官網(wǎng)定制、小程序開發(fā)服務(wù),打造橫峰網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供橫峰網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。C#如何計(jì)算傳入的時(shí)間距離今天的時(shí)間差的實(shí)例分享
/// <summary> /// 計(jì)算傳入的時(shí)間距離今天的時(shí)間差 /// </summary> /// <param name="dt"></param> /// <param name="yy"></param> /// <param name="mm"></param> /// <param name="dd"></param> public void GetCriminalYX(DateTime dt, out int yy, out int mm, out int dd) { DateTime now = DateTime.Now; yy = mm = dd = 0; if (dt.Year > 9000 || dt.Year == 1900) { return; } if (dt <= now) { return; } StringBuilder str = new StringBuilder(); int dt_Y = dt.Year; int dt_M = dt.Month; int dt_D = dt.Day; int now_Y = DateTime.Now.Year; int now_M = DateTime.Now.Month; int now_D = DateTime.Now.Day; yy = dt_Y - now_Y; mm = dt_M - now_M; dd = 0; int dt_M_SY = 0; if (dt_D < now_D) { mm -= 1; dt_M_SY = dt_M - 1; if (dt_M_SY == 0) { dt_M_SY = 12; } if (dt_M_SY == 2) { dt_M_SY = dt_Y % 4 == 0 ? 29 : 28; } else { dt_M_SY = dt_M_SY == 2 || dt_M_SY == 4 || dt_M_SY == 6 || dt_M_SY == 9 || dt_M_SY == 11 ? 30 : 31; } dt_D += dt_M_SY; } dd = dt_D - now_D; if (mm < 0) { yy -= 1; mm += 12; } }
感謝各位的閱讀!關(guān)于C#中計(jì)算傳入的時(shí)間距離今天的時(shí)間差的案例就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
網(wǎng)頁標(biāo)題:C#中計(jì)算傳入的時(shí)間距離今天的時(shí)間差的案例-創(chuàng)新互聯(lián)
瀏覽地址:http://www.rwnh.cn/article2/dsopic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、外貿(mào)建站、全網(wǎng)營銷推廣、服務(wù)器托管、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容