C# 判断月初月末
DateTime now = DateTime.Now; DateTime firstDayOfMonth = new DateTime(now.Year, now.Month, 1); DateTime lastDayOfMonth = new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month)); if (now.Date == firstDayOfMonth.Date) { MessageBox.Show("当前时间是月初"); } else if (now.Date == lastDayOfMonth.Date) { MessageBox.Show("当前时间是月末"); } else { MessageBox.Show("当前时间既不是月初也不是月末"); }

浙公网安备 33010602011771号