Php calculates the number of days, hours, minutes, seconds, and instance code of two time differences.
Php calculates the number of days, hours, minutes, And seconds in different time ranges.
In PHP, calculating the number of days, hours, minutes, And seconds in different time periods is not as convenient as other languages, but it is also very easy to understand the Time Representation Method in PHP. This article describes how to calculate the time difference in php. For more information about the coders, see.
Let's take a look at the following online example:
// $ Startdate indicates the start time and $ enddate indicates the end time. <? Php $ startdate = "11:50:00"; $ enddate = "12:12:12"; $ date = floor (strtotime ($ enddate)-strtotime ($ startdate)/86400 ); echo "Days different :". $ date. "Day <br/>"; $ hour = floor (strtotime ($ enddate)-strtotime ($ startdate) % 86400/3600); echo "hours of difference: ". $ hour. "hour <br/>"; $ minute = floor (strtotime ($ enddate)-strtotime ($ startdate) % 86400/60); echo "number of minutes of difference: ". $ minute. "Minutes <br/>"; $ second = floor (strtotime ($ endda Te)-strtotime ($ startdate) % 86400% 60); echo "seconds of Difference:". $ second. "seconds";?>
Whether it is the time type constructed by yourself using strings (converted by strtotime) or the time type obtained by using the system's time function, it is actually a variable with a long integer. Two such variables can obviously be used for subtraction.
After subtraction, the value is the number of seconds of the difference. If the number of seconds is the remainder of 86400 (the number of seconds in a day), the number of differences is obtained. If the modulo value is set to 86400 and the remainder value is set to 3600 s and 60 s, the related hours and minutes are obtained. If the modulo is set to 86400 and the modulo is set to 60, the number of seconds is returned.
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!