Calculating the time difference in php is sometimes troublesome!
However, I believe that any language, as long as it holds the rule rate, will be able to find a way, it is absolutely magical.
Date calculation is often performed in the work. The following is a summary of the experience gained from the work. Remember it first so that you will not forget it later!
1. The first calculation time period difference (which can be minute, second, or day)
$ Endtime = "18:10:00 ";
$ D1 = substr ($ endtime, 17,2); // second
$ D2 = substr ($ endtime, 14,2); // minute
$ D3 = substr ($ endtime, 11, 2); // hour
$ D4 = substr ($ endtime, 8, 2); // day
$ D5 = substr ($ endtime, 5, 2); // month
$ D6 = substr ($ endtime, 0, 4); // year
Echo $ d1. '-'. $ d2. '-'. $ d3. '-'. $ d5. '-'. $ d4. '-'. $ d6. "n ";
Echo date ("Y-m-d H: I: s"). "n ";
$ Now_T = mktime (date ("H"), date ("I"), date ("s"), date ("m"), date ("d "), date ("Y "));
Echo $ now_T. "n ";
$ Now_S = mktime ("$ d3", "$ d2", "$ d1", "$ d5", "$ d4", "$ d6 ");
Echo $ now_S. "n ";
$ End_TS = ($ now_S-$ now_T)/60; // calculate the remaining minutes
Echo $ end_TS;
?>
Note $ startdate = mktime ("0", "0", "0", "1", "1", "2000 ");
// The obtained value is the total number of seconds from January 1, 3600 to the parameter time. You can convert it to minute/60, 3600/24 days, or!
If the parameter in mktime () defaults, the current date is used.
2. It would be easy to have a database! If it is MSSQL, you can use a trigger! Use the datediff () function that specifically calculates the date difference!
If MYSQL is used, the calculation result calculated using the difference value of two date fields is saved in another numeric field! It can be called in time!