TimeDay

Returns the day of month from a Unix timestamp.

Syntax

TimeDay(unixTimeSeconds: number): number

Parameters

  • unixTimeSeconds: number - Unix timestamp in seconds since epoch

Return Value

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

Description

The TimeDay method extracts the day of month from a given Unix timestamp. The returned value is between 1 and 31, depending on the month.

Example

// Get day from timestamp
const timestamp = 1707739200; // 2024.02.12 12:00:00 UTC
const day = this.api.TimeDay(timestamp);
console.log(`Day: ${day}`);

// Format with leading zero
const formattedDay = day.toString().padStart(2, "0");
console.log(`Formatted day: ${formattedDay}`);

// Check for month end
const month = this.api.TimeMonth(timestamp);
const year = this.api.TimeYear(timestamp);
const lastDayOfMonth = new Date(year, month, 0).getDate();
const isMonthEnd = day === lastDayOfMonth;
console.log(`Is month end: ${isMonthEnd}`);

// Format full date
console.log(`Date: ${year}.${month}.${formattedDay}`);

Last updated