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
Depend on month
var date = new Date();
var quarter = parseInt(date.getMonth() / 3 ) + 1 ;
Depend on Date
var date = new Date();
var firstday = new Date(date.getFullYear(),0,1); // XXXX/01/01
var diff = Math.ceil((date - firstday) / 86400000);
// a quarter is about 365/4
quarter = parseInt( diff / ( 365/ 4 )) + 1
// if today is 2012/01/01, the value of quarter is 1.