Month
Syntax
Month(): numberReturn Value
Description
Example
// Get current month
const month = this.api.Month();
console.log(`Current month: ${month}`);
// Format month with leading zero
const formattedMonth = month.toString().padStart(2, "0");
console.log(`Formatted month: ${formattedMonth}`);
// Get month name
const monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
console.log(`Month name: ${monthNames[month - 1]}`);
// Check for specific months
if (month === 1) {
console.log("First month of the year");
} else if (month === 12) {
console.log("Last month of the year");
}
// Check for quarter end
if (month % 3 === 0) {
console.log("End of quarter");
}Last updated