TimeSeconds

Returns the seconds from a Unix timestamp.

Syntax

TimeSeconds(unixTimeSeconds: number): number

Parameters

  • unixTimeSeconds: number - Unix timestamp in seconds since epoch

Return Value

Returns a number representing the seconds (0-59).

Description

The TimeSeconds method extracts the seconds from a given Unix timestamp. The returned value is between 0 and 59.

Example

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

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

// Create full time string
const hour = this.api.TimeHour(timestamp);
const minute = this.api.TimeMinute(timestamp);
console.log(`Time: ${hour}:${minute}:${formattedSeconds}`);

// Calculate seconds until next minute
const secondsUntilNextMinute = 60 - seconds;
console.log(`Seconds until next minute: ${secondsUntilNextMinute}`);

Last updated