Browse Source

倒计时加上小时

lizhen_gitee 9 months ago
parent
commit
1f195d5f63
1 changed files with 14 additions and 4 deletions
  1. 14 4
      application/common.php

+ 14 - 4
application/common.php

@@ -943,9 +943,14 @@ if(!function_exists('Sec2Time')) {
     function Sec2Time($time){
         if(is_numeric($time)){
             $value = array(
-                'minutes' => 0, 'seconds' => 0,
+                'hour' => 0, 'minutes' => 0, 'seconds' => 0,
             );
 
+            if($time >= 3600){
+                $value['hour'] = floor($time/3600);
+                $time = ($time%3600);
+            }
+
             if($time >= 60){
                 $value['minutes'] = floor($time/60);
                 $time = ($time%60);
@@ -953,7 +958,7 @@ if(!function_exists('Sec2Time')) {
 
             $value['seconds'] = floor($time);
 
-            $t = $value['minutes'] .' 分 '.$value['seconds'].' 秒';
+            $t = $value['hour'] .' 小时 '.$value['minutes'] .' 分 '.$value['seconds'].' 秒';
             return $t;
 
         }else{
@@ -966,9 +971,14 @@ if(!function_exists('Sec2Time_en')) {
     function Sec2Time_en($time){
         if(is_numeric($time)){
             $value = array(
-                'minutes' => 0, 'seconds' => 0,
+                'hour' => 0, 'minutes' => 0, 'seconds' => 0,
             );
 
+            if($time >= 3600){
+                $value['hour'] = floor($time/3600);
+                $time = ($time%3600);
+            }
+
             if($time >= 60){
                 $value['minutes'] = floor($time/60);
                 $time = ($time%60);
@@ -976,7 +986,7 @@ if(!function_exists('Sec2Time_en')) {
 
             $value['seconds'] = floor($time);
 
-            $t = $value['minutes'] .' Minutes and '.$value['seconds'].' Seconds';
+            $t = $value['hour'] .' hour and '.$value['minutes'] .' Minutes and '.$value['seconds'].' Seconds';
             return $t;
 
         }else{