Js 获取 本周、本月起始时间】的更多相关文章

//获取本日 const startDate = moment().format('YYYY-MM-DD'); const startDate = moment().format('YYYY-MM-DD'); //获取本周 const startDate = moment().week(moment().week()).startOf('week').format('YYYY-MM-DD'); //这样是年月日的格式 const endDate = moment().week(moment().…
js 获取 本周.上周.本月.上月.本季度.上季度的开始结束日期 /**  * 获取本周.本季度.本月.上月的开始日期.结束日期  */ var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getYear(); //当前年 no…
js获取当地时间并且拼接时间格式,在stackoverflow上有人在问,查了资料,各种方法将时间格式改成任意自己想要的样式. 1. var date = new Date(+new Date()+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,''); console.log(date);//2017-01-22 11:08:46 var date = new Date(+new Date()+8*3600*1…
js 获取开始时间和结束时间相隔小时及分钟(时间戳操作) 场景描述:获取开始时间和结束时间相隔小时及分钟 实例: TimeOnConfirm(curDate) { if(this.pickernum == 1){ //开始时间 startTime = moment(curDate).format("YYYY-MM-DD HH:mm") }else if(this.pickernum == 2) { 结束时间 endTime = moment(curDate).format("…
工具类定义: /** * 日期范围工具类 */ var dateRangeUtil = (function () { /*** * 获得当前时间 */ this.getCurrentDate = function () { return new Date(); }; /*** * 获得本周起止时间 */ this.getCurrentWeek = function () { //起止日期数组 var startStop = new Array(); //获取当前时间 var currentDat…
/** * 针对时间的工具类 */ var DateTimeUtil = function () { /*** * 获得当前时间 */ this.getCurrentDate = function () { return new Date(); }; /*** * 获得本周起止时间 */ this.getCurrentWeek = function () { //起止日期数组 var startStop = new Array(); //获取当前时间 var currentDate = this…
/** * 获取本周.本季度.本月.上月的开始日期.结束日期 */ var now = new Date();                    //当前日期 var nowDayOfWeek = now.getDay();         //今天本周的第几天 var nowDay = now.getDate();              //当前日 var nowMonth = now.getMonth();           //当前月 var nowYear = now.getY…
这两天在做一个报表体统,其中涉及到了一个根据本周,上周,本月,上月的时间来进行查询的问题,在这个我就教一下大家怎么实现,大家如果有更好的实现方法的,我也希望大家能说出来,我们交流交流. 首先呢,我写了一个方法,能实现获取本周,上周的开始时间,并且解决了跨年的问题 在这里先说明一下,月份,周几都是从0开始的这一点是需要我们注意的. 本周,上周的开始结束时间 function getTime(n){ var now=new Date(); var year=now.getFullYear(); //…
/** * 获取本周.本季度.本月.上月的开始日期.结束日期 */ var now = new Date(); //当前日期  var nowDayOfWeek = now.getDay(); //今天本周的第几天  var nowDay = now.getDate(); //当前日  var nowMonth = now.getMonth(); //当前月  var nowYear = now.getYear(); //当前年  nowYear += (nowYear < 2000) ? 19…
/** * 获取本周.本季度.本月.上月的开始日期.结束日期 */ var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getYear(); //当前年 nowYear += (nowYear < 2000) ? 1900 :…