月份累计加减
$.date = function (dateObject) {
var d = new Date(dateObject);
var day = d.getDate();
var month = d.getMonth() + 1;
var year = d.getFullYear();
if (day < 10) {
day = "0" + day;
}
if (month < 10) {
month = "0" + month;
}
var date = year + "-" + month;
return date;
};
var myDate=new Date();
var curmonth = $.date(new Date(myDate.getFullYear(), myDate.getMonth() + 1, 1, 12));//获取下个月
var nextmonth = $.date(new Date(myDate.getFullYear(), myDate.getMonth() + 2, 1, 12));//往后第二个月
var nextnextmonth = $.date(new Date(myDate.getFullYear(), myDate.getMonth() + 3, 1, 12));//往后第三个月
/// <summary>
/// 获取本周的周一日期
/// </summary>
/// <returns></returns>
public static string GetThisWeekMonday()
{
DateTime date = DateTime.Now;
DateTime firstDate = System.DateTime.Now;
switch (date.DayOfWeek)
{
case System.DayOfWeek.Monday:
firstDate = date;
break;
case System.DayOfWeek.Tuesday:
firstDate = date.AddDays(-1);
break;
case System.DayOfWeek.Wednesday:
firstDate = date.AddDays(-2);
break;
case System.DayOfWeek.Thursday:
firstDate = date.AddDays(-3);
break;
case System.DayOfWeek.Friday:
firstDate = date.AddDays(-4);
break;
case System.DayOfWeek.Saturday:
firstDate = date.AddDays(-5);
break;
case System.DayOfWeek.Sunday:
firstDate = date.AddDays(-6);
break;
}
return firstDate.ToString("yyyy-MM-dd");
}