TA贡献1893条经验 获得超10个赞
您将在该月的最后一天返回31:
DateTime.DaysInMonth(1980, 08);
TA贡献1725条经验 获得超7个赞
如果要给定一个月和一年的日期,这似乎是正确的:
public static DateTime GetLastDayOfMonth(this DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, DateTime.DaysInMonth(dateTime.Year, dateTime.Month));
}
举报
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号