Second
Syntax
Second(): numberReturn Value
Description
Example
// Get current second
const second = this.api.Second()
console.log(`Current second: ${second}`)
// Format second with leading zero
const formattedSecond = second.toString().padStart(2, '0')
console.log(`Formatted second: ${formattedSecond}`)
// Create full time string
const hour = this.api.Hour()
const minute = this.api.Minute()
const timeString = `${hour}:${minute}:${formattedSecond}`
console.log(`Current time: ${timeString}`)
// Check for minute boundary
const isStartOfMinute = second === 0
if (isStartOfMinute) {
console.log('New minute started')
}
// Calculate seconds until next minute
const secondsUntilNextMinute = 60 - second
console.log(`Seconds until next minute: ${secondsUntilNextMinute}`)
// Check for time intervals
const isHalfSecond = second % 30 === 0
if (isHalfSecond) {
console.log('Half-minute mark')
}Last updated