C# 获取月份天数的三种方法
方法一:
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(DateTime.Now.Year ,DateTime.Now.Month);
方法二:
DateTime dtNow = DateTime.Today;
int days = dtNow .AddDays( – dtNow .Day).AddMonths().AddDays(-).Day;
方法三:
DateTime dtNow = DateTime.Now;
int days = DateTime.DaysInMonth(dtNow.Year ,dtNow.Month);
获取当前月份数
string k=DateTime.Now.Month.ToString();
string sMonth = DateTime.Now.ToString(“MM”);
DateTime.Now.Month.ToString(“00”);
获取年份数
string k=DateTime.Now.Year.ToString();
获取天数差
DateTime jtsj = Convert.ToDateTime(args.DataRow["F_PVPX_JTSJ"]);
DateTime dtNow = DateTime.Today;
int days =(jtsj-dtNow).Days;