Css.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Sports\Controller;
  3. use BaseController\Controller;
  4. use Biz\Match\GetmatchData;
  5. class Css extends Controller {
  6. public function index(){
  7. $data['s_time'] =$this->getMsecToMescdate(time());
  8. $s = $_REQUEST['data'];
  9. $arr = [];
  10. if(strstr($s,',')){
  11. $arr1 = explode(",", $s);
  12. if(!empty($arr1)){
  13. foreach($arr1 as $k=>$v){
  14. $arr[]= (int)$v*100;
  15. }
  16. }
  17. }else{
  18. for($i=0;$i<=$s;$i++){
  19. $arr[] = $i+1;
  20. }
  21. }
  22. $data['num'] = count($arr);
  23. $data['e_time'] =$this->getMsecToMescdate(time());
  24. Render($data, '1', lang('Tips','Sports')->get('success'));
  25. }
  26. //获取毫秒级时间
  27. public function getMsecToMescdate($msectime)
  28. {
  29. $msectime = $msectime * 0.001;
  30. if(strstr($msectime,'.')){
  31. sprintf("%01.3f",$msectime);
  32. list($usec, $sec) = explode(".",$msectime);
  33. $sec = str_pad($sec,3,"0",STR_PAD_RIGHT);
  34. }else{
  35. $usec = $msectime;
  36. $sec = "000";
  37. }
  38. $date = date("Y-m-d H:i:s.x",$usec);
  39. $mescdate = str_replace('x', $sec, $date);
  40. return $mescdate;
  41. }
  42. }