This is the PHP code that can be specific to the hour
Copy Code code as follows:
/* Author: Yangyu yangyu@sina.cn * *
Enter two timestamps, calculate the difference, that is, the difference of the number of hours, such as the return of 2:10, indicates that the two times entered the difference between 2 hours and 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;
}
here is the specific to the number of days of the function code JS
Copy 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 <strong style= ' color:red ' > ' +time+ ' </strong> days! ';} </script>
Date Difference days Online computing tool