Wrong lastActiveAt in user detail

We are receiving old lastActiveAt in below API

                res => {})

Hello @mubashshir,

Can you please share the exact code snippet of how you are converting the timestamp into the Date?

I did run a few tests and the last active at seems to be working fine on my end. I am sharing a code snippet to get the last active at of a user below.

    res => {
        console.log('lastActiveAt', res.getStatus() === 'offline' ? new Date(res.getLastActiveAt() * 1000) : 'active');

I hope this helps. Please let us know if you face any issues.

Warm Regards,

CometChat Pro
Mayur Bhandari

I am using the property ‘lastActiveAt’ like this
new Date(res.lastActiveAt * 1000)
and it brings some old date while the user is active at the moment.

Hello @mubashshir,

If the user is active then you will get the lastActiveAt as his older lastActiveAt. Since the user is active/online, using the lastActiveAt doesn’t make any sense. I am unable to understand what issue you are facing exactly or what are you trying to achieve by using lastActiveAt of an active user. Please elaborate more on the issue and your use case, so that i can help you better.

Warm Regards,

CometChat Pro
Mayur Bhandari

I want to show the last seen of user.
The scenario is as.
A user comes everyday online so he is active everyday. but when i get his details then it shows sometime correct date but sometime it brings old date

Hows lastActiveAt work, what is the logic behind it.
If i am using wrong way then what is the other option to get the last seen of any user

Hello @mubashshir
Can you please share the UID of the user/users for whom you are getting incorrect values of lastActiveAt so that we can check this at our end. It would really help us investigate this in a better way and provide you with a solution at the earliest.


Please find below userid for user Aditya Kumar
uid: “17386”

Hello @mubashshir,
There could be a possibility where the user for which you are checking the lastActiveAt has never logged in to CometChat. In this case, the lastActiveAt field will be set to 0. This situation will have to be handled at your end in the client-side code. You need to check if the lastActiveAt field for the user is not 0 and only then display the last seen for the user.
If the lastActiveAt field is set to 0, you can display a custom text displaying that the user has never logged in.

Hope this helps.



It was for logged in user and it brought the some old date.
i will let you know by testing it again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.