TimeCurrent

Returns the current time.

Syntax

TimeCurrent(): FTODate

Return Value

Returns an FTODatearrow-up-right object representing the current time.

Description

The TimeCurrent method returns the current time as an FTODatearrow-up-right object. This time represents the timestamp of the last processed tick in the project. The returned FTODatearrow-up-right object provides various methods for date and time manipulation.

Example

// Get current time
const currentTime = this.api.TimeCurrent();

// Display current time components
console.log(
  `Date: ${currentTime.yearOf()}.${currentTime.monthOf()}.${currentTime.dayOfMonth()}`
);
console.log(
  `Time: ${currentTime.hour()}:${currentTime.minute()}:${currentTime.second()}`
);

// Get timestamp in milliseconds
const timestamp = currentTime.getTime();
console.log(`Timestamp: ${timestamp}`);

// Format the date
console.log(`Formatted date: ${currentTime.toString()}`);

// Check if it's weekend
const dayOfWeek = currentTime.dayOfWeek();
const isWeekend = dayOfWeek === 0 || dayOfWeek === 6;
console.log(`Is weekend: ${isWeekend}`);

Last updated