# How do I get the user's call duration? (/en/api-reference/faq/integration/call_duration)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

During a call, a user may join and leave a Video SDK channel for multiple times, and the user's call duration is the actual time when the user is in the channel. You can use the Agora Video SDK or Agora Analytics to get a user's call duration.

## Implementation [#implementation]

### Use the Agora Video SDK [#use-the-agora-video-sdk]

By design, the SDK triggers the [`onRtcStats`](https://api-ref.agora.io/en/video-sdk/android/3.x/classio_1_1agora_1_1rtc_1_1_i_rtc_engine_event_handler.html#ada7aa10b092a6de23b598a9f77d4deee) callback after a user successfully joins a Video SDK channel. To get the duration between each channel-join and channel-leave, use the `totalDuration` parameter of the last `onRtcStats` callback triggered before the user leaves the channel. If a user joins and leaves a Video SDK channel for multiple times, you can calculate the user's call duration by adding up the values of `totalDuration`.

The above callback is in Java. For other programming languages, use the following parameters to get the user's call duration:

* C++: The `duration` parameter of the `onRtcStats` callback.
* Objective-C: The `duration` parameter of the [`reportRtcStats`](https://api-ref.agora.io/en/video-sdk/ios/3.x/Protocols/AgoraRtcEngineDelegate.html#//api/name/rtcEngine\:reportRtcStats:) callback.
* JavaScript: The `Duration` parameter of the `Client.getSessionStats` method.

If the connection is lost under poor network conditions, the calculated duration may be inaccurate. Use [Agora Signaling SDK](/en/signaling/develop/manage-connection-states) or a different signaling system to implement a heartbeat mechanism, and get the disconnected time of the client. You can calculate the user's call duration by subtracting the disconnected time of the client from the call duration obtained from the Agora Video SDK.

### Use Agora Analytics [#use-agora-analytics]

On the **Call Search** page of **Agora Analytics**, you can find a user's call duration in the **In-call Periods** column. See [Call Search](/en/agora-analytics/analyze/video-voice-sdk/call-search#use-call-search).

![](https://web-cdn.agora.io/docs-files/1592406406894)
