You can retrieve the current time of the Controller from the API endpoint:

https://<hostname>:<port>/api/

Use the currentTime value to determine for how long an Element or monitor is in its current status. (For example, refer to the Incident Panel gadget.) Note that this value is from the Controller's timezone.

For outage calculation, you can determine the difference between this value and a specific monitor or Element's lastTransitionTime value.