This is the php code specific to the hour.
Copy codeThe Code is as follows:
/* Author: Yang yuyangyu@sina.cn */
// Enter two timestamps to calculate the difference value, that is, the number of hours of the difference. If the return value is, the difference between the two input time ranges by 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;
}
Below is the function code js specific to the number of days
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 = 'date difference <strong style = "color: red"> '+ time +' </strong> day! ';}</Script>
Date difference days online computing tool