This is a PHP code that can be specific to hours.
Copy CodeThe code is 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 CodeThe code is 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
http://www.bkjia.com/PHPjc/321113.html www.bkjia.com true http://www.bkjia.com/PHPjc/321113.html techarticle This is can be specific to the hours of PHP code copy Code code as follows:/* Author: Yangyu yangyu@sina.cn *///Input two timestamp, calculate the difference, that is, the difference in the number of hours, such as return ...