'wordpress CF7 get current quarter in year with jQuery function
this script calculate the correct quarter of the year, but i should calculate the value based on the selected first date :-( can you help me, please?
/* Javascript */
jQuery(function ($) {
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear()+"-"+(month)+"-"+(day);
$('#MydatePicker').val(today);
/* $("#MydatePicker").attr("min", today); */
});
jQuery(function ($) {
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear()+"-"+(month)+"-"+(day);
var quarter;
if (month < 4)
quarter = 1;
else if (month < 7)
quarter = 2;
else if (month < 10)
quarter = 3;
else if (month < 13)
quarter = 4;
$('#trimestre').val(quarter);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
