DateTimeUtils.cs 662 B

123456789101112131415161718192021222324252627
  1. using System;
  2. namespace cuidian.Common
  3. {
  4. public class DateTimeUtils
  5. {
  6. /// <summary>
  7. /// 获得月初日期
  8. /// </summary>
  9. /// <param name="date"></param>
  10. /// <returns></returns>
  11. public static DateTime GetFirstMonthDate(DateTime date)
  12. {
  13. return new DateTime(date.Year, date.Month, 1);
  14. }
  15. /// <summary>
  16. /// 获得月末日期
  17. /// </summary>
  18. /// <param name="date"></param>
  19. /// <returns></returns>
  20. public static DateTime GetEndMonthDate(DateTime date)
  21. {
  22. return date.AddMonths(1).AddDays(-1);
  23. }
  24. }
  25. }