Day

Returns the current day of month.

Syntax

Day(): number

Return Value

Returns a number representing the day of the month (1-31).

Description

The Day method returns the day of the month for the current time. The returned value is between 1 and 31, depending on the month.

Example

// Get current day of month
const day = this.api.Day()
console.log(`Current day: ${day}`)

// Check if it's the first day of month
if (this.api.Day() === 1) {
    console.log('First day of the month')
}

// Check if it's end of month
if (this.api.Day() >= 28) {
    // Additional logic needed for accurate end-of-month check
    console.log('Approaching end of month')
}

// Format date with leading zero if needed
const formattedDay = this.api.Day().toString().padStart(2, '0')
console.log(`Formatted day: ${formattedDay}`)

Last updated