This is a PHP code that can be specific to hours.
Copy the Code code as follows:
/* Author: Yangyu yangyu@sina.cn */
Enter two timestamp, calculate the difference, that is, the number of hours of difference, such as return 2:10, that is, the two time difference between the input 2 hours 10 minutes
function Hours_min ($start _time, $end _time) {
if (Strtotime ($start _time) > Strtotime ($end _time)) List ($start _time, $end _time) = Array ($end _time, $start _time);
$sec = $start _time-$end _time;
$sec = round ($sec/60);
$min = Str_pad ($sec%60, 2, 0, str_pad_left);
$hours _min = Floor ($sec/60);
$min! = 0 && $hours _min. = ': '. $min;
return $hours _min;
}
The following is a specific to the number of days of the function code JS
Copy the Code code as follows:
function Get_date_different () {
var _date_1 = document.getElementById (' date1 '). Value.replace (/(^\s*) | ( \s*$)/g, ");
var _date_2 = document.getElementById (' Date2 '). Value.replace (/(^\s*) | ( \s*$)/g, ");
_date_1 = new Date (_date_1);
_date_2 = new Date (_date_2);
var days= _date_2.gettime ()-_date_1.gettime ();
var time = parseint (days/(1000 * 60 * 60 * 24));
document.getElementById (' content '). InnerHTML = ' Two date difference ' +time+ ' days! ';}
Date Difference days Online calculation tool
The above describes the PHP calculation of two time intervals between the function hours, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.