TimeLocal

Returns the current local time.

Syntax

TimeLocal(): FTODate

Return Value

Returns an FTODate object representing the current local time.

Description

The TimeLocal method returns the current local time as an FTODate object. This time is adjusted according to the project's timezone settings and includes daylight savings time adjustments if applicable.

Example

// Get current local time
const localTime = this.api.TimeLocal();
console.log(`Local time: ${localTime.toString()}`);

// Compare with GMT time
const gmtTime = this.api.TimeGMT();
console.log(`GMT time: ${gmtTime.toString()}`);

// Calculate timezone offset
const offsetInHours =
  (localTime.getTime() - gmtTime.getTime()) / (1000 * 60 * 60);
console.log(`Timezone offset: ${offsetInHours} hours`);

// Format local time components
console.log(
  `Local Date: ${localTime.yearOf()}.${localTime.monthOf()}.${localTime.dayOfMonth()}`
);
console.log(
  `Local Time: ${localTime.hour()}:${localTime.minute()}:${localTime.second()}`
);

// Check DST status
const dstOffset = this.api.TimeDaylightSavings();
const isDST = dstOffset > 0;
console.log(`DST is in effect: ${isDST}`);

Last updated