timeToSec() Function

Convert an HH:MM or HH:MM:SS time string to seconds — build duration and scheduling calculators.

formulas functions time

timeToSec()

Convert a time string (HH:MM or HH:MM:SS) to seconds — use as the first step in duration, billing, or scheduling calculators.


Syntax

Every formula in Calcopolis must start with = in the Value field:

= timeToSec("HH:MM")
Part Rule
Function name timeToSec — camelCase
Arguments One — a quoted time string
Formats "HH:MM" or "HH:MM:SS" (24-hour style)
Return value Total seconds (0 if the format is invalid)

Valid examples

= timeToSec("02:30")
= timeToSec("01:15:00")
= timeToSec(start_time)

Invalid / unsupported

Don't write Why
timeToSec(02:30) Time must be a quoted string
timeToSec("2:30 PM") Use 24-hour HH:MM, not AM/PM text
timeToSec("90") Minutes-only strings are not supported — use HH:MM

Parameters

Argument Description
timeStr Time as text. Examples: "01:00" (1 hour), "00:45" (45 minutes).

When to use timeToSec()

Use timeToSec() to normalize times before math:

Situation What timeToSec() does
Duration Difference between start and end times
Billable hours Convert logged time to seconds, then to hours
SLA timers Compare elapsed time against a threshold

Pair with [secToTime()](/docs/reference/formulas/sec-to-time-function/) to show results as clock time again.


Practical examples (ecommerce & leads)

1. Meeting duration from two Text fields

start_time and end_time hold values like "09:00" and "10:30".

Variable Formula
duration_sec = timeToSec(end_time) - timeToSec(start_time)
duration_hours = duration_sec / 3600

2. Billable block over 15 minutes

Variable Formula
billable_sec = max(timeToSec(worked_time) - timeToSec("00:15"), 0)

Where to use it

Location Supported
Result widget Value Yes — = ... formulas
Standalone variable (Variables tab) Yes
Number / other input default Value Yes, if formula-driven
Visibility formula Yes
Custom Text / Table cells No — use {{ }} templates there, not = functions

After editing, run Calculate (or enable Run calculation on load in project Options) to refresh results.


← Back to Reference

Still have unanswered questions?

We are here to help. Reach out and our team will get back to you.

Contact support