Summary of php time computing issues. Specific: 1 as we know the start time, to add or subtract a time, to get a result of time, you can use the following code $ time12008-10-112: 30: 30; echodate (Y-m-dH: i: s, strtotime ($ time1 details:
1> if we know the start time, we need to add or subtract a time to get a result time, you can use the following code
$ Time1 = '2017-10-1 12:30:30 ';
Echo date ('Y-m-d H: I: S', strtotime ($ time1) + 30*60); // pay attention to the case in the quotation marks. the minute is that I is not m
Execution result: 13:00:30
2> to calculate the difference between the two time points, use the following method:
$ Time1 = '2017-10-1 12:30:30 ';
$ Time2 = '2017-10-1 13:45:30 ';
$ Diff = (strtotime ($ time2)-strtotime ($ time1)/60;
Echo $ time1. 'to'. $ time2. 'time difference'. $ diff. 'mine ';
Result: The time difference between 12:30:30 and 13:45:30 is 75 minutes.
Summary: php time computing is based on seconds. after grasping this rule, the time difference can be converted to minutes or hours, making time computing very simple and easy.
If we know the start time and need to add or subtract a time to get a result time, we can use the following code $ time1 = '2017-10-1 12:30:30 '; echo date ('Y-m-d H: I: S', strtotime ($ time1...