#region 得到一个月的第一天和最后一天的日期
/// <summary>
/// 得到本月的第一天日期
/// </summary>
/// <returns>DateTime</returns>
public static DateTime GetFirstDayOfMonth()
{
return GetFirstDayOfMonth(DateTime.Now);
}
/// <summary>
/// 得到本月的最有一天的日期
/// </summary>
/// <returns>DateTime</returns>
public static DateTime GetLastDayOfMonth()
{
return GetLastDayOfMonth(DateTime.Now);
}
/// <summary>
/// 得到一个月的第一天
/// </summary>
/// <param name="someday">这个月的随便一天</param>
/// <returns>DateTime</returns>
public static DateTime GetFirstDayOfMonth(DateTime someday)
{
int totalDays = DateTime.DaysInMonth(someday.Year, someday.Month);
DateTime result;
int ts = 1 - someday.Day;
result = someday.AddDays(ts);
return result;
}
/// <summary>
/// 得到一个月的最后一天
/// </summary>
/// <param name="someday">这个月的随便一天</param>
/// <returns>DateTime</returns>
public static DateTime GetLastDayOfMonth(DateTime someday)
{
int totalDays = DateTime.DaysInMonth(someday.Year, someday.Month);
DateTime result;
int ts = totalDays - someday.Day;
result = someday.AddDays(ts);
return result;
}
#endregion
标签:
asp.net,日期

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com