彭俊 6 سال پیش
والد
کامیت
402363994c
1فایلهای تغییر یافته به همراه19 افزوده شده و 2 حذف شده
  1. 19 2
      Application/Sports/Controller/Css.php

+ 19 - 2
Application/Sports/Controller/Css.php

@@ -10,7 +10,7 @@ use Biz\Match\GetmatchData;
 class  Css extends Controller {
 
     public function index(){
-        $data['s_time'] =$this->getMsecToMescdate(time());
+        $data['s_time'] =$this->ts_time();
         $s = $_REQUEST['data'];
         $arr = [];
         if(strstr($s,',')){
@@ -27,7 +27,7 @@ class  Css extends Controller {
             }  
         }
         $data['num'] = count($arr);
-        $data['e_time'] =$this->getMsecToMescdate(time());
+        $data['e_time'] =$this->ts_time();
 
 
         Render($data, '1', lang('Tips','Sports')->get('success'));
@@ -49,4 +49,21 @@ class  Css extends Controller {
         $mescdate = str_replace('x', $sec, $date);
         return $mescdate;
     }
+
+    /**
+     * 年月日、时分秒 + 3位毫秒数
+     * @param string $format
+     * @param null $utimestamp
+     * @return false|string
+     */
+    public function ts_time($format = 'Y-m-d H:i:s.u', $utimestamp = null) {
+        if (is_null($utimestamp)){
+            $utimestamp = microtime(true);
+        }
+    
+        $timestamp = floor($utimestamp);
+        $milliseconds = round(($utimestamp - $timestamp) * 1000);
+    
+        return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp);
+    }
 }