TimeYear
Syntax
TimeYear(unixTimeSeconds: number): numberParameters
Return Value
Description
Example
// Get year from timestamp
const timestamp = 1707739200; // 2024.02.12 12:00:00 UTC
const year = this.api.TimeYear(timestamp);
console.log(`Year: ${year}`);
// Check if leap year
const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
console.log(`Is leap year: ${isLeapYear}`);
// Calculate years between timestamps
const timestamp2 = 1676203200; // 2023.02.12 12:00:00 UTC
const year2 = this.api.TimeYear(timestamp2);
const yearsDiff = year - year2;
console.log(`Years difference: ${yearsDiff}`);
// Format full date
const month = this.api.TimeMonth(timestamp);
const day = this.api.TimeDay(timestamp);
console.log(`Date: ${year}.${month}.${day}`);Last updated