We want to set a time out for viewing the document(Docx, pdf, excel files) in SharePoint based on the time.so, for example, we want the document to be activated for a certain user only for 3 hours after the user opens it for the first time and the time gets deducted for the next visit to the document, is it possible/?
OOTB's approach doesn't meet your needs, sharePoint doesn't have a setting for viewing time.
Karthikeyan's approach may seem like a good choice, but it doesn't fully meet your needs.
According to my research, there are no corresponding steps in the workflow to calculate the last time you viewed a document and to calculate the time left to view the document.
Your needs may not be fully met.
We don't have any OOTB approach to achieve this but we can give the workaround solution using SP workflow.
Follow the below steps
1.Trigger the workflow as per your need (Item Created/ Item Modified)
2.Add Impersonation step to the workflow
3.Add item level permission
4.Send an email notification to represent user/group
5.Pause the workflow for next 3 hours
6.Remove the item level permission for those users
7.Stop the workflow