日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

js获取下月时间_js 获取日期时间段

發布時間:2025/3/19 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 js获取下月时间_js 获取日期时间段 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/**

* DateUtil.js 日期工具包 時間:2011-02-12 注:1天=86400000毫秒 郵箱:jrunner@126.com

*/

function DateUtil() {

this.WeekDay;// 星期幾

this.WeekDayStr;

this.Day;// 當天

this.Year;// 當年

this.Month;// 當月

this.Hours;// 當前小時

this.Minutes;

this.Seconds;

this.Time;// 當前事件

var Nowdate = new Date();

this.WeekDay = Nowdate.getDay();

this.Month = Nowdate.getMonth();

this.Day = Nowdate.getDate();

this.Year = Nowdate.getFullYear();

this.WeekDayStr = '星期' + '日一二三四五六'.charAt(this.WeekDay)

this.Hours = Nowdate.getHours();

this.Minutes = Nowdate.getMinutes();

this.Seconds = Nowdate.getSeconds();

this.Time = this.Year + "-" + (this.Month + 1) + "-" + this.Day + " "

+ this.Hours + ":" + this.Minutes + ":" + this.Seconds;

// 今天

this.showCurrentDay = function() {

return Nowdate;

};

// 本周第一天

this.showWeekFirstDay = function() {

var WeekFirstDay = new Date(Nowdate - (this.WeekDay - 1) * 86400000);

return WeekFirstDay;

};

// 本周最后一天

this.showWeekLastDay = function() {

var WeekFirstDay = this.showWeekFirstDay();

var WeekLastDay = new Date((WeekFirstDay / 1000 + 6 * 86400) * 1000);

return WeekLastDay;

};

// 本月第一天

this.showMonthFirstDay = function() {

var MonthFirstDay = new Date(this.Year, this.Month, 1);

return MonthFirstDay;

};

// 本月最后一天

this.showMonthLastDay = function() {

var MonthNextFirstDay = new Date(this.Year, this.Month + 1, 1);

var MonthLastDay = new Date(MonthNextFirstDay - 86400000);

return MonthLastDay;

};

// 當年第一天

this.showYearFirstDay = function() {

var YearFirstDay = new Date(this.Year, 0, 1);

return YearFirstDay;

};

// 當年最后一天

this.showYearLastDay = function() {

var YearNextFirstDay = new Date(this.Year + 1, 0, 1);

var YearLastDay = new Date(YearNextFirstDay - 86400000);

return YearLastDay;

};

// 上年第一天

this.showYearPreviousFirstDay = function() {

var YearPreviousFirstDay = new Date(this.Year - 1, 0, 1);

return YearPreviousFirstDay;

};

// 上年最后一天

this.showYearPreviousLastDay = function() {

var YearFirstDay = this.showYearFirstDay();

var YearPreviousLastDay = new Date(YearFirstDay - 86400000);

return YearPreviousLastDay;

};

// 下年第一天

this.showYearNextFirstDay = function() {

var YearNextFirstDay = new Date(this.Year + 1, 0, 1);

return YearNextFirstDay;

};

// 下年最后一天

this.showYearNextLastDay = function() {

var step = new Date(this.Year + 2, 0, 1);

var YearNextLastDay = new Date(step - 86400000);

return YearNextLastDay;

};

// 上月第一天

this.showPreviousFirstDay = function() {

var MonthFirstDay = this.showMonthFirstDay()

return new Date(MonthFirstDay.getFullYear(), MonthFirstDay.getMonth()

- 1, 1)

};

// 上月最后一天

this.showPreviousLastDay = function() {

var MonthFirstDay = this.showMonthFirstDay();

return new Date(MonthFirstDay - 86400000);

};

// 上周第一天

this.showPreviousFirstWeekDay = function() {

var WeekFirstDay = this.showWeekFirstDay()

return new Date(WeekFirstDay - 86400000 * 7)

};

// 上周最后一天

this.showPreviousLastWeekDay = function() {

var WeekFirstDay = this.showWeekFirstDay()

return new Date(WeekFirstDay - 86400000)

};

// 上一天

this.showPreviousDay = function() {

var MonthFirstDay = new Date();

return new Date(MonthFirstDay - 86400000);

};

// 下一天

this.showNextDay = function() {

var MonthFirstDay = new Date();

return new Date((MonthFirstDay / 1000 + 86400) * 1000);

};

// 下周第一天

this.showNextFirstWeekDay = function() {

var MonthFirstDay = this.showWeekLastDay()

return new Date((MonthFirstDay / 1000 + 86400) * 1000)

};

// 下周最后一天

this.showNextLastWeekDay = function() {

var MonthFirstDay = this.showWeekLastDay()

return new Date((MonthFirstDay / 1000 + 7 * 86400) * 1000)

};

// 下月第一天

this.showNextFirstDay = function() {

var MonthFirstDay = this.showMonthFirstDay()

return new Date(MonthFirstDay.getFullYear(), MonthFirstDay.getMonth()

+ 1, 1)

};

// 下月最后一天

this.showNextLastDay = function() {

var MonthFirstDay = this.showMonthFirstDay()

return new Date(new Date(MonthFirstDay.getFullYear(), MonthFirstDay

.getMonth()

+ 2, 1)

- 86400000)

};

// 返回json

this.toObject = function(startTime, endTime) {

var obj = {

start : startTime.getFullYear() + "-" + (startTime.getMonth() + 1)

+ "-" + startTime.getDate(),

end : endTime.getFullYear() + "-" + (endTime.getMonth() + 1) + "-"

+ endTime.getDate()

};

return obj;

}

};

// 上一年 {start:2010-01-01 00:00:00,end:2010-12-31 23:59:59}

DateUtil.prototype.PreviousYear = function() {

return this.toObject(this.showYearPreviousFirstDay(), this

.showYearPreviousLastDay());

};

// 本年 {start:2011-01-01 00:00:00,end:2011-12-31 23:59:59}

DateUtil.prototype.CurrentYear = function() {

return this.toObject(this.showYearFirstDay(), this.showYearLastDay());

};

// 下一年 {start:2012-01-01 00:00:00,end:2012-12-31 23:59:59}

DateUtil.prototype.NextYear = function() {

return this.toObject(this.showYearNextFirstDay(), this

.showYearNextLastDay());

};

// 上一月 {start:2011-01-01 00:00:00,end:2011-01-31 23:59:59}

DateUtil.prototype.PreviousMonth = function() {

return this.toObject(this.showPreviousFirstDay(), this

.showPreviousLastDay());

};

// 本月 {start:2011-02-01 00:00:00,end:2011-02-28 23:59:59}

DateUtil.prototype.CurrentMonth = function() {

return this.toObject(this.showMonthFirstDay(), this.showMonthLastDay());

};

// 下一月 {start:2011-03-01 00:00:00,end:2011-03-31 23:59:59}

DateUtil.prototype.NextMonth = function() {

return this.toObject(this.showNextFirstDay(), this.showNextLastDay());

};

// 上一周

DateUtil.prototype.PreviousWeekDay = function() {

return this.toObject(this.showPreviousFirstWeekDay(), this

.showPreviousLastWeekDay());

};

// 本周

DateUtil.prototype.CurrentWeekDay = function() {

return this.toObject(this.showWeekFirstDay(), this.showWeekLastDay());

};

// 下一周

DateUtil.prototype.NextWeekDay = function() {

return this.toObject(this.showNextFirstWeekDay(), this

.showNextLastWeekDay());

};

// 上一天

DateUtil.prototype.PreviousDay = function() {

return this.toObject(this.showPreviousDay(), this.showPreviousDay());

};

// 今天

DateUtil.prototype.CurrentDay = function() {

return this.toObject(this.showCurrentDay(), this.showCurrentDay());

};

// 下一天

DateUtil.prototype.NextDay = function() {

return this.toObject(this.showNextDay(), this.showNextDay());

};

下載次數: 22

分享到:

2012-06-06 12:24

瀏覽 4102

評論

總結

以上是生活随笔為你收集整理的js获取下月时间_js 获取日期时间段的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。