Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bor1904's avatar

Best way to counting SLA times

Hi, I want to create HelpDesk system with counting SLA times feature. Different SLA times are depend on priority or person type who submit the ticket. Additionaly I need funcionality to pause tickets to stop caounting SLA time for this ticket (more then one time in ticket life).

I wondering what way is the best to make this mechanism...

Have you some experience with similar counting time mechanisms?

Thanks in advance!

KB

0 likes
3 replies
vmitchell85's avatar

You could probably do some calculation from the created_at date of the ticket. Any time you view the ticket you could update a viewed_at timestamp or something similar.

Hope this makes sense.

Snapey's avatar

I would create a status table for each ticket (1:many) this would track the status history

when the ticket is opened, create a row with just the start time, and give it a status

when the ticket is closed, fill in the last row with an end time and the duration (end minus start) and a closed status

If the ticket is paused, close the current open row, add in the duration and create a new row with a start time and paused status

If the ticket comes off pause, close the previous pause row and start a new row with a new start time

At any time, the sla clock is the duration of the previous open rows. if the ticket is still open you can calculate the duration of the latest row and add in the durations of the previous open rows

1 like
bor1904's avatar

Thanks Guys! The idea with status table is great and I'm going to use this approach but... I still have some problem.

Sometimes SLA time is counted in business hours, sometimes 24/7 - it is depend on ticket priority which is changable (due the life of ticket). In example user (client) create a ticket and this ticket by default has normal prio (=SLA in business hours), but when agent check the message inside the ticket many times he must chage prio to HIGH (=SLA 24/7).

What is the best way to count SLA when we have on the one hand SLA-breaks caused by status and on the other hand SLA-breaks caused by time ?

thanks for the suggestions!

Please or to participate in this conversation.