讓TextBox1呈現「今天」的日期!!!
- TextBox1.Text = DateTime.Now.ToString( );
→ 進階-指定日期的格式:
DateTime.Now.ToString("yyyy/MM/dd");
→呈現格式(如):2014/11/17
---------------------------------------------------
昨天日期:
- DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd");
→呈現格式(如):2014/11/16
----------------------------------------------------
明天日期:
- DateTime.Now.AddDays(1).ToString("yyyy/MM/dd");
→呈現格式(如):2014/11/18
--------------------------------------------------
上個月日期:
DateTime.Parse(DateTime.Now.ToString("yyyy/MM/dd")).AddMonths(-1).ToShortDateString( );
--------------------------------------------------
下個月日期:
DateTime.Parse(DateTime.Now.ToString("yyyy/MM/dd")).AddMonths(1).ToShortDateString( );
--------------------------------------------------
本年度第一天:
DateTime.Parse(DateTime.Now.ToString("yyyy/01/01")).ToStringDateString( );
--------------------------------------------------
本年度最後一天:
DateTime.Parse(DateTime.Now.ToString("yyyy/01/01")).AddYears(1).AddDays(-1).ToStringDateString( );