HR issues, how do I register, employee login delay

I want to make the employee, if he logs in late, record in the system that he is late and calculate the number of hours. If I want to send a notification email alerting the employee, call this value and it will tell me how many times the employee is late.

I know that there must be a condition, but how do I arrange it so that the output becomes what I want?