How to calculate the time of any procedure. For example, I go into the system, do some actions, and when I go out the system gives the time I spent in the system in the format - ЧЧ:ММ:СС ?

  • use the microtime () function - splash58

2 answers 2

If you need to know the time to work out a script, then use microtime() , as suggested in the comment. Call the function before the test, save the result, call after, save the result - the difference between the two results will be the desired value. If you need to find out the user's time in a section, save the time in the session when the user started, record the time when he finished, and again, the difference between these two values ​​will be the result.

  • But with this fix the time when he finished, there will be no difficulties? How to do it? - splash58
  • it is difficult to say in isolation from the specific system and specific process. for example, user interaction with the checkout module - from the first item in the basket to the purchase. In general, there should be no difficulties if the interaction process clearly implies a specific result: an order made, a published post, etc. - Igor Karpenko
  • and ... from pressing a button to pressing is yes :) - splash58
  • operator interaction with the system is, for the most part, pressing buttons) - Igor Karpenko

If you need time in the system, i.e. logout time - logon time, then simply record the user logon / logout time into the database, and then read.