如何在文本框中计算未来3个月的日期? [英] how to calculate next 3 month for date in textbox ?

查看:79
本文介绍了如何在文本框中计算未来3个月的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在文本框中计算接下来3个月的日期?

how to calculate next 3 month for date in textbox ?

推荐答案

您正在寻找:



今天日期后两周:

Are you looking for like :

Two weeks after today's date:
DateTime.Now.Date.AddDays(2*7)



$ / b $ b或



今天日期后三个月:



Or

Three months after today's date:

DateTime.Now.Date.AddMonths(3)




假设您从文本框中获取日期为01/01/2013​​,您可以使用

C#代码



string date = txt
Hi
Suppose you get the date from text box is "01/01/2013" the in
C# code you can use

string date = txt
fname.Text.ToString();  // you text box date
            var d = date.Split('/');
            int day =Convert.ToInt16(  d[0]);
            int month =Convert.ToInt16(  d[1]);
            int year =Convert.ToInt16( d[2]);

            DateTime newdate =new DateTime(year, month, day).AddMonths(3);





我希望它可以帮到你。

谢谢你



I hope it helps you .
thank you


这篇关于如何在文本框中计算未来3个月的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆