GetMonthByDateTime

Returns the month from an FTODate object.

Syntax

GetMonthByDateTime(ftoDate: FTODate): number

Parameters

  • ftoDate: FTODate - The FTODate object to extract the day from

Return Value

Returns a number representing the month (1-12).

Description

The GetMonthByDateTime method extracts the month from an FTODate object. The returned value is between 1 and 12, where 1 represents January and 12 represents December.

Example

// Create FTODate object
const currentDate = this.api.TimeCurrent();
const month = this.api.GetMonthByDateTime(currentDate);
console.log(`Month: ${month}`);

// Format 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 quarter end
const isQuarterEnd = month % 3 === 0;
console.log(`Is quarter end: ${isQuarterEnd}`);

// Format full date
const year = currentDate.yearOf();
const day = currentDate.dayOfMonth();
console.log(`Date: ${year}.${formattedMonth}.${day}`);

Last updated