js怎样获取本季度28日下午16:00:00的时间戳?
从来没有了到还需要科普季度的知识
来自百度百科
人们俗称的“季度”,就是把一年平均分成四份,按照春、夏、秋、冬的顺序
一年可以分为四个季度,每个季度历时3个月。
第一季度:1月-3月
第二季度:4月-6月
第三季度:7月-9月
第四季度:10月-12月
而实际上严格的划分应该为:(按照中国的纬度)
第一季度:3-5月(春季)
第二季度:6-8月(夏季)
第三季度:9-11月(秋季)
第四季度:12-2月(冬季)
问题应改为 求当前季度最后一个月28日16点时间戳
var currentDate = new Date();
var currentSeasonLastMonth = Math.ceil((currentDate.getMonth() + 1)/3)*3;
var currentSeasonLast28 = new Date(currentDate.getFullYear(), currentSeasonLastMonth-1, 28, 16, 0);
console.log(currentSeasonLast28.valueOf()); //打印出当季最后一个月28日16点的时间戳
<script>
var now = new Date;
var nowMonth = now.getMonth() + 1;
if(nowMonth>=1 && nowMonth<=3){
now.setMonth(2); //这个地方应该是3-1=2
}else if(nowMonth>=4 && nowMonth<=6){
now.setMonth(5);
}else if(nowMonth>=7 && nowMonth<=9){
now.setMonth(8);
}else if(nowMonth>=10 && nowMonth<=12){
now.setMonth(11);
}
now.setDate(28);
now.setHours(16);
now.setMinutes( 0, 0, 0 );
console.log("当前时间", now, "时间戳", now.getTime())
</script>
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答843 阅读✓ 已解决
3 回答1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
请问季度28日存在吗, 我还想知道本世纪28日是哪一天.