用js根据当前季度获取上一季度
来源:互联网 发布:双色球246包中6红矩阵 编辑:程序博客网 时间:2024/06/09 15:56
var myDate = new Date();
var today= myDate.toLocaleDateString();//获取当前日期
var strYear = myDate.getFullYear();
var strMonth = myDate.getMonth() + 1;
var strQuarter = Math.floor((strMonth % 3 == 0 ? (strMonth / 3) : (strMonth / 3 + 1)));
strYear=((strQuarter==1)?(strYear-1):(strYear));
var today= myDate.toLocaleDateString();//获取当前日期
var strYear = myDate.getFullYear();
var strMonth = myDate.getMonth() + 1;
var strQuarter = Math.floor((strMonth % 3 == 0 ? (strMonth / 3) : (strMonth / 3 + 1)));
strYear=((strQuarter==1)?(strYear-1):(strYear));
strQuarter=((strQuarter==1)?(4):(strQuarter-1));
注意:当日期为01-01---03-31是也就是第一季度的时候,我们需要把年-1也就是上一年的第四季度
顺便:我写了个获取当前日期。
(可以参考一下根据当前日期进行判断获取上一季度)
这里我就写这么一种方法,另一种方法大神可以讨论分享一下
1 0
- 用js根据当前季度获取上一季度
- 根据当前日期获取当前季度范围
- 用系统函数获取当前季度
- linux 根据当前日期获取上个季度的第一天和最后一天
- C#根据当前时间获取周,月,季度,年度等时间段的起止时间
- php根据年月获取季度示例
- jquery 根据当前元素获取上一级下一级元素
- js根据当前时间获取指定范围内的时间段日期
- js根据当前日期获取下一周日期
- js获取 本周,本月,本季度,本年,上月,上周,上季度,去年
- js获取 本周,本月,本季度,本年,上月,上周,上季度,去年
- js 获取 本周、上周、本月、上月、本季度、上季度的开始结束日期
- js 获取 本周、上周、本月、上月、本季度、上季度的开始结束日期
- js获取 本周,本月,本季度,本年,上月,上周,上季度,去年
- js与date有关方法2(获取本周,本月,本季度,本年,上月,上周,上季度,去年)
- JS 获取 本周、本月、本季度、本年、上月、上周、上季度、去年
- Java获取时间范围: 当前季度,上个季度,昨天,当前月,上个月
- 获取上周上季度上月等时间
- VC6.0工程设置
- android监听应用缓存和任务栈顶的方法
- java设计模式:观察者模式实例详解(基于java内置观察者)
- 对单一职责原则的理解
- Method Swizzling(iOS的hook机制)
- 用js根据当前季度获取上一季度
- 查看Linux内核源码技巧的记录
- android中的提示方法
- 正则表达式不以某字符串结尾
- MySQL面试题目
- a* 求次短路 《路由选择问题》
- C++类继承下的赋值运算符
- RH413企业安全加固 第10章 管理 PAM
- jquery遍历给每个子元素绑定事件