GetLastDayOfMonth
Gets the last date of the month of the DateTime.
Source
public static DateTime GetLastDayOfMonth(this DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1).AddDays(-1);
}
Example
DateTime lastDay = DateTime.Now.GetLastDayOfMonth();