Get current quarter in year with javascript

后端 未结 9 1079
有刺的猬
有刺的猬 2020-12-13 02:10

How can I get the current quarter we are in with javascript? I am trying to detect what quarter we are currently in, e.g. 2.

EDIT And how can I coun

9条回答
  •  孤街浪徒
    2020-12-13 03:04

    This worked for me!

    var d = new Date();
    var quarter = Math.ceil(d.getMonth() / 3);
    
    console.log(quarter)

提交回复
热议问题