I have the store start time as microtime() and end time as microtime() into database.
Now I want to calculate how long the script takes the seconds/minutes/hours to execute.
How can I do in PHP?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
basically, like this:
$endtime-$starttimegives the duration in seconds, date is used to format the output. sounds like saving to and reading from a database isn’t your problem here, so i left that out in my example. Note that you’ll have to usemicrotime(true)to get this working, with the space-separated output ofmicrotime()your can’t do calculations that easy.EDIT: you could do all the calculation on your own, too. it’s just basic math like this: